summaryrefslogtreecommitdiff
path: root/libopie
authorllornkcor <llornkcor>2002-04-24 03:22:24 (UTC)
committer llornkcor <llornkcor>2002-04-24 03:22:24 (UTC)
commit219994e9d1de70b44c994ccee57060741f22d428 (patch) (side-by-side diff)
tree2acfcae2a6bfc432266ee1d0cb76285a95fe683f /libopie
parentc9159a3d5192799f5b2911d13337f04f50b1ac5a (diff)
downloadopie-219994e9d1de70b44c994ccee57060741f22d428.zip
opie-219994e9d1de70b44c994ccee57060741f22d428.tar.gz
opie-219994e9d1de70b44c994ccee57060741f22d428.tar.bz2
fixed location combo showing redundant directories and multiple seperators
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc123
-rw-r--r--libopie/ofileselector.h15
2 files changed, 111 insertions, 27 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index cb18039..d1f1e1f 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -44,2 +44,4 @@
#include <qcursor.h>
+#include <qstringlist.h>
+#include <qmessagebox.h>
@@ -136,2 +138,3 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
}
+
void OFileSelector::initPics()
@@ -153,3 +156,4 @@ void OFileSelector::initPics()
-};
+}
+
// let's initialize the gui
@@ -181,2 +185,3 @@ void OFileSelector::delItems()
}
+
void OFileSelector::init()
@@ -218,3 +223,3 @@ void OFileSelector::init()
-};
+}
@@ -263,2 +268,3 @@ void OFileSelector::setPermissionBarVisible( bool show )
}
+
void OFileSelector::setLineEditVisible( bool show )
@@ -278,2 +284,3 @@ void OFileSelector::setLineEditVisible( bool show )
}
+
void OFileSelector::setChooserVisible( bool show )
@@ -291,2 +298,3 @@ void OFileSelector::setChooserVisible( bool show )
}
+
QCheckBox* OFileSelector::permissionCheckbox( )
@@ -295,2 +303,3 @@ QCheckBox* OFileSelector::permissionCheckbox( )
}
+
void OFileSelector::setCaseSensetive( bool caSe )
@@ -300,2 +309,3 @@ void OFileSelector::setCaseSensetive( bool caSe )
}
+
void OFileSelector::setShowFiles(bool files ){
@@ -304,2 +314,3 @@ void OFileSelector::setShowFiles(bool files ){
}
+
void OFileSelector::setPopupMenu(QPopupMenu *pop )
@@ -309,2 +320,3 @@ void OFileSelector::setPopupMenu(QPopupMenu *pop )
}
+
bool OFileSelector::setPermission( ) const
@@ -316,2 +328,3 @@ bool OFileSelector::setPermission( ) const
}
+
void OFileSelector::setPermissionChecked( bool check )
@@ -322,2 +335,3 @@ void OFileSelector::setPermissionChecked( bool check )
}
+
QString OFileSelector::selectedName( )const
@@ -336,2 +350,3 @@ QString OFileSelector::selectedName( )const
}
+
QStringList OFileSelector::selectedNames()const
@@ -341,2 +356,3 @@ QStringList OFileSelector::selectedNames()const
}
+
DocLnk OFileSelector::selectedDocument( )const
@@ -387,2 +403,3 @@ void OFileSelector::updateLay()
}
+
// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
@@ -434,2 +451,3 @@ void OFileSelector::reparse()
};
+
QDir dir( m_currentDir );
@@ -499,6 +517,9 @@ void OFileSelector::reparse()
}
+
QString OFileSelector::directory()const
{
- return m_currentDir;
+ QDir d( m_currentDir);
+ return d.absPath();
}
+
int OFileSelector::fileCount()
@@ -507,2 +528,3 @@ int OFileSelector::fileCount()
}
+
void OFileSelector::slotOk( )
@@ -511,2 +533,3 @@ void OFileSelector::slotOk( )
}
+
void OFileSelector::slotCancel( )
@@ -528,2 +551,3 @@ void OFileSelector::initializeName()
}
+
void OFileSelector::initializeYes()
@@ -543,2 +567,3 @@ void OFileSelector::initializeYes()
}
+
void OFileSelector::initializeChooser()
@@ -572,2 +597,3 @@ void OFileSelector::initializeChooser()
}
+
void OFileSelector::slotMimeCheck(const QString &view ){
@@ -647,3 +673,3 @@ void OFileSelector::slotViewCheck(const QString &view ){
};
-};
+}
@@ -667,3 +693,4 @@ void OFileSelector::updateMimes() // lets check which mode is active
}
-};
+}
+
void OFileSelector::initializeListView()
@@ -695,2 +722,3 @@ void OFileSelector::initializeListView()
m_location = new QComboBox(m_pseudo );
+ connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) );
@@ -807,2 +835,3 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink )
}
+
void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
@@ -844,2 +873,3 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
}
+
void OFileSelector::setShowDirs(bool dir )
@@ -858,2 +888,3 @@ void OFileSelector::slotFileSelected(const QString &string )
}
+
void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
@@ -863,2 +894,3 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
}
+
void OFileSelector::slotSelectionChanged() // get the current items
@@ -868,2 +900,3 @@ void OFileSelector::slotSelectionChanged() // get the current items
}
+
void OFileSelector::slotCurrentChanged(QListViewItem *item )
@@ -887,2 +920,3 @@ void OFileSelector::slotCurrentChanged(QListViewItem *item )
}
+
// either select or change dir
@@ -903,11 +937,11 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
if(sel->isDir() ){
- cd( sel->directory() + "/" + str[0] );
- }else{
- qWarning("file" );
- if(m_shLne )
- m_edit->setText(str[0] );
- emit fileSelected(str[0] );
- // emit DocLnk need to do it
+ cd( sel->directory() + "/" + str[0] );
+ } else {
+ qWarning("file" );
+ if(m_shLne )
+ m_edit->setText(str[0] );
+ emit fileSelected(str[0] );
+ // emit DocLnk need to do it
}
- }else{
+ } else {
qWarning( "locked" );
@@ -916,2 +950,3 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
}
+
void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
@@ -926,2 +961,3 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin
}
+
void OFileSelector::slotContextMenu(QListViewItem *item)
@@ -977,2 +1013,3 @@ void OFileSelector::slotContextMenu(QListViewItem *item)
}
+
bool OFileSelector::cd(const QString &str )
@@ -982,7 +1019,7 @@ bool OFileSelector::cd(const QString &str )
if(dir.exists() ){
- m_currentDir = str;
+ m_currentDir = dir.absPath();
reparse();
if(m_shTool ){
- int count = m_location->count();
- m_location->insertItem(str );
+ int count = m_location->count();
+ insertLocationPath( str ,count );
m_location->setCurrentItem( count );
@@ -994,2 +1031,17 @@ bool OFileSelector::cd(const QString &str )
+void OFileSelector::insertLocationPath(const QString &currentPath, int count) {
+ QStringList pathList;
+ for(int i=0;i<count;i++) {
+ pathList << m_location->text(i);
+ }
+ if( pathList.grep( currentPath,TRUE).isEmpty() ) {
+ m_location->clear();
+ if( currentPath.left(2)=="//")
+ pathList.append( currentPath.right(currentPath.length()-1) );
+ else
+ pathList.append( currentPath );
+ m_location->insertStringList( pathList,-1);
+ }
+}
+
void OFileSelector::slotChangedDir()
@@ -1000,4 +1052,6 @@ void OFileSelector::slotChangedDir()
cd( sel->directory() + "/" + str[0] );
+
}
}
+
void OFileSelector::slotOpen()
@@ -1010,2 +1064,3 @@ void OFileSelector::slotOpen()
}
+
void OFileSelector::slotRescan()
@@ -1014,2 +1069,3 @@ void OFileSelector::slotRescan()
}
+
void OFileSelector::slotRename()
@@ -1018,2 +1074,3 @@ void OFileSelector::slotRename()
}
+
void OFileSelector::slotDelete()
@@ -1024,5 +1081,10 @@ void OFileSelector::slotDelete()
if( sel->isDir() ){
- QString str = QString::fromLatin1("rm -rf ") + list[0];
- ::system(str.utf8().data() );
- }else{
+ QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry
+ switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
+ tr("Yes"),tr("No"),0,1,1) ) {
+ case 0:
+ ::system(str.utf8().data() );
+ break;
+ }
+ } else {
QFile::remove( list[0] );
@@ -1041,6 +1103,18 @@ void OFileSelector::cdUP()
int count = m_location->count();
- m_location->insertItem(m_currentDir );
- m_location->setCurrentItem( count );
+ insertLocationPath( m_currentDir,count );
+ m_location->setCurrentItem( indexFromString(m_currentDir ));
+//this wont work in all instances
+ // FIXME
}
}
+
+int OFileSelector::indexFromString(const QString &str) {
+
+ for(int i=0;i< m_location->count();i++) {
+ if(str == m_location->text(i))
+ return i;
+ }
+ return 0;
+}
+
void OFileSelector::slotHome()
@@ -1049,2 +1123,3 @@ void OFileSelector::slotHome()
}
+
void OFileSelector::slotDoc()
@@ -1053,2 +1128,3 @@ void OFileSelector::slotDoc()
}
+
void OFileSelector::slotNavigate()
@@ -1057 +1133,6 @@ void OFileSelector::slotNavigate()
}
+
+void OFileSelector::locationComboActivated(const QString & file ) {
+ cd(file.left(file.find("<-",0,TRUE)));
+ reparse();
+}
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 5e98a1e..81a9e63 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -69,4 +69,4 @@ class OFileSelectorItem : public QListViewItem {
OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path,
- const QString &date, const QString &size, const QString &mDir,
- bool isLocked=false, bool isDir=false ): QListViewItem(view) {
+ const QString &date, const QString &size, const QString &mDir,
+ bool isLocked=false, bool isDir=false ): QListViewItem(view) {
setPixmap(0, pixmap );
@@ -96,7 +96,7 @@ class OFileSelectorItem : public QListViewItem {
if( dir ){
- ke.append("0" );
- ke.append( text(1) );
+ ke.append("0" );
+ ke.append( text(1) );
}else{
- ke.append("1" );
- ke.append( text(1) );
+ ke.append("1" );
+ ke.append( text(1) );
}
@@ -192,2 +192,5 @@ class OFileSelector : public QWidget {
void slotMimeCheck(const QString & );
+ void locationComboActivated(const QString & );
+ void insertLocationPath(const QString &, int);
+ int indexFromString(const QString &);
protected: