summaryrefslogtreecommitdiff
path: root/libopie/ofileselector/ofilelistview.cpp
Unidiff
Diffstat (limited to 'libopie/ofileselector/ofilelistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/ofileselector/ofilelistview.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp
index 9cfdc48..fe8acf0 100644
--- a/libopie/ofileselector/ofilelistview.cpp
+++ b/libopie/ofileselector/ofilelistview.cpp
@@ -37,68 +37,68 @@ OFileListView::OFileListView( QWidget* parent, OFileSelector* sel)
37 connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 37 connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
38 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 38 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
39} 39}
40OFileListView::~OFileListView() { 40OFileListView::~OFileListView() {
41 41
42} 42}
43void OFileListView::clear() { 43void OFileListView::clear() {
44 QListView::clear(); 44 QListView::clear();
45} 45}
46void OFileListView::addFile( const QPixmap& pix, 46void OFileListView::addFile( const QPixmap& pix,
47 const QString&, 47 const QString&,
48 QFileInfo* info, 48 QFileInfo* info,
49 const QString& /*extra*/, 49 const QString& extra,
50 bool isSymlink ) { 50 bool isSymlink ) {
51 QString dir; 51 QString dir;
52 QString name; 52 QString name;
53 bool locked = false; 53 bool locked = false;
54 54
55 dir = info->dirPath( true ); 55 dir = info->dirPath( true );
56 56
57 if( isSymlink ) 57 if( isSymlink )
58 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); 58 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
59 else { 59 else {
60 name = info->fileName(); 60 name = info->fileName();
61 if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) || 61 if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
62 ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){ 62 ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
63 63
64 locked = true; 64 locked = true;
65 } 65 }
66 } 66 }
67 new OFileSelectorItem( this, pix, name, 67 new OFileSelectorItem( this, pix, name,
68 info->lastModified().toString(), 68 info->lastModified().toString(),
69 QString::number( info->size() ), 69 QString::number( info->size() ),
70 dir, locked ); 70 dir, locked, extra );
71} 71}
72void OFileListView::addFile( const QPixmap&, 72void OFileListView::addFile( const QPixmap&,
73 const QString& /*mime*/, const QString& /*dir*/, 73 const QString& /*mime*/, const QString& /*dir*/,
74 const QString& /*file*/, 74 const QString& /*file*/,
75 const QString& /*extra*/, 75 const QString& /*extra*/,
76 bool /*isSyml*/ ) { 76 bool /*isSyml*/ ) {
77 77
78} 78}
79void OFileListView::addDir( const QPixmap& pix, const QString&, 79void OFileListView::addDir( const QPixmap& pix, const QString&,
80 QFileInfo* info, 80 QFileInfo* info,
81 const QString& /*extra */, 81 const QString& extra ,
82 bool symlink ) { 82 bool symlink ) {
83 83
84 bool locked = false; 84 bool locked = false;
85 QString name; 85 QString name;
86 86
87 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; 87 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
88 88
89 new OFileSelectorItem( this, pix, name, 89 new OFileSelectorItem( this, pix, name,
90 info->lastModified().toString(), 90 info->lastModified().toString(),
91 QString::number( info->size() ), 91 QString::number( info->size() ),
92 info->dirPath( true ), locked, 92 info->dirPath( true ), locked, extra,
93 true ); 93 true );
94 94
95} 95}
96void OFileListView::addDir( const QPixmap&, 96void OFileListView::addDir( const QPixmap&,
97 const QString& /*mime*/, const QString& /*dir*/, 97 const QString& /*mime*/, const QString& /*dir*/,
98 const QString& /*file*/, 98 const QString& /*file*/,
99 const QString& /*extra*/, 99 const QString& /*extra*/,
100 bool ) { 100 bool ) {
101 101
102} 102}
103void OFileListView::addSymlink( const QPixmap&, 103void OFileListView::addSymlink( const QPixmap&,
104 const QString& /*mime*/, 104 const QString& /*mime*/,
@@ -118,86 +118,84 @@ void OFileListView::cd( const QString& ) {
118 118
119} 119}
120QWidget* OFileListView::widget() { 120QWidget* OFileListView::widget() {
121 return this; 121 return this;
122} 122}
123QString OFileListView::selectedName()const{ 123QString OFileListView::selectedName()const{
124 QListViewItem *item = currentItem(); 124 QListViewItem *item = currentItem();
125 if (!item ) 125 if (!item )
126 return QString::null; 126 return QString::null;
127 127
128 return item->text( 1 ); 128 return item->text( 1 );
129} 129}
130QString OFileListView::selectedExtra()const{
131 QListViewItem* item = currentItem();
132 if (!item) return QString::null;
133 OFileSelectorItem* fit = (OFileSelectorItem*)fit;
134
135 return fit->extra();
136}
130QStringList OFileListView::selectedNames()const { 137QStringList OFileListView::selectedNames()const {
131 QStringList list; 138 QStringList list;
132 list << selectedName(); 139 list << selectedName();
133 return list; 140 return list;
134} 141}
135QString OFileListView::selectedPath()const { 142QString OFileListView::selectedPath()const {
136 return QString::null; 143 return QString::null;
137} 144}
138QStringList OFileListView::selectedPaths()const { 145QStringList OFileListView::selectedPaths()const {
139 QStringList list; 146 QStringList list;
140b list << selectedPath(); 147 list << selectedPath();
141 return list; 148 return list;
142} 149}
143int OFileListView::fileCount() { 150int OFileListView::fileCount() {
144 return childCount(); 151 return childCount();
145} 152}
146void OFileListView::sort() { 153void OFileListView::sort() {
147 QListView::sort(); 154 QListView::sort();
148} 155}
149void OFileListView::slotSelectionChanged() { 156void OFileListView::slotSelectionChanged() {
150 157
151} 158}
152void OFileListView::slotCurrentChanged( QListViewItem* item) { 159void OFileListView::slotCurrentChanged( QListViewItem* item) {
153 if (!item ) 160 if (!item )
154 return; 161 return;
155 162
156 OFileSelectorItem* sel = (OFileSelectorItem*) item; 163 OFileSelectorItem* sel = (OFileSelectorItem*) item;
157 164
158 qWarning("current changed"); 165 qWarning("current changed");
159 if(!sel->isDir() ){ 166 if(!sel->isDir() ){
160 updateLine( sel->text(1) ); 167 updateLine( sel->text(1) );
161 168
162 if (selector()->mode() == OFileSelector::Fileselector ) { 169 if (selector()->mode() == OFileSelector::Fileselector ) {
163 QStringList str = QStringList::split("->", sel->text(1) ); 170 QStringList str = QStringList::split("->", sel->text(1) );
164 QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); 171 fileSelected(sel->directory(), str[0].stripWhiteSpace(),sel->extra() );
165 DocLnk lnk( path );
166 fileSelected(lnk );
167 fileSelected( path );
168 } 172 }
169 } 173 }
170} 174}
171void OFileListView::slotClicked( int button, QListViewItem* item, 175void OFileListView::slotClicked( int button, QListViewItem* item,
172 const QPoint&, int ) { 176 const QPoint&, int ) {
173 if ( !item ) 177 if ( !item )
174 return; 178 return;
175 179
176 if( button != Qt::LeftButton ) 180 if( button != Qt::LeftButton )
177 return; 181 return;
178 182
179 OFileSelectorItem *sel = (OFileSelectorItem*)item; 183 OFileSelectorItem *sel = (OFileSelectorItem*)item;
180 184
181 if(!sel->isLocked() ){ 185 if(!sel->isLocked() ){
182 QStringList str = QStringList::split("->", sel->text(1) ); 186 QStringList str = QStringList::split("->", sel->text(1) );
183 if( sel->isDir() ){ 187 if( sel->isDir() ){
184 changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); 188 changedDir( sel->directory(), str[0].stripWhiteSpace(),sel->extra() );
185 }else{ 189 }else{
186 updateLine( str[0].stripWhiteSpace() ); 190 updateLine( str[0].stripWhiteSpace() );
187 QString path = sel->directory(); 191 fileSelected( sel->directory(),str[0].stripWhiteSpace(), sel->extra() );
188 path += "/";
189 path += str[0].stripWhiteSpace();
190
191 DocLnk lnk( path );
192 fileSelected( path );
193 fileSelected( lnk );
194 } 192 }
195 } 193 }
196} 194}
197void OFileListView::slotRightButton( int button, QListViewItem* item, 195void OFileListView::slotRightButton( int button, QListViewItem* item,
198 const QPoint&, int ) { 196 const QPoint&, int ) {
199 if (!item || (button != Qt::RightButton )) 197 if (!item || (button != Qt::RightButton ))
200 return; 198 return;
201 199
202 /* raise contextmenu */ 200 /* raise contextmenu */
203} 201}