By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release. View | Details | Raw Unified | Return to bug 2644
Collapse All | Expand All

(-)a/ark/filelistview.cpp (-63 / +25 lines)
Lines 72-84 int FileLVI::compare( TQListViewItem * i, int column, bool ascending ) const Link Here
72
72
73
	if ( ( this->childCount() > 0 ) && ( item->childCount() == 0 ) )
73
	if ( ( this->childCount() > 0 ) && ( item->childCount() == 0 ) )
74
		return -1;
74
		return -1;
75
	
75
76
	if ( ( this->childCount() == 0 ) && ( item->childCount() > 0 ) )
76
	if ( ( this->childCount() == 0 ) && ( item->childCount() > 0 ) )
77
		return 1;
77
		return 1;
78
78
79
	if ( column == 0 )
79
	if ( column == 0 )
80
		return TDEListViewItem::compare( i, column, ascending );
80
		return TDEListViewItem::compare( i, column, ascending );
81
	
81
82
	columnName colName = ( static_cast< FileListView * > ( listView() ) )->nameOfColumn( column );
82
	columnName colName = ( static_cast< FileListView * > ( listView() ) )->nameOfColumn( column );
83
	switch ( colName )
83
	switch ( colName )
84
	{
84
	{
Lines 170-175 void FileLVI::setText( int column, const TQString &text ) Link Here
170
		TQListViewItem::setText(column, text);
170
		TQListViewItem::setText(column, text);
171
}
171
}
172
172
173
void FileLVI::setItemData( const TQStringList &entryData )
174
{
175
	int i = 0;
176
177
	for (TQStringList::ConstIterator it = entryData.begin(); it != entryData.end(); ++it)
178
	{
179
		this->setText(i, *it);
180
		++i;
181
	}
182
}
183
173
static FileLVI* folderLVI( TDEListViewItem *parent, const TQString& name )
184
static FileLVI* folderLVI( TDEListViewItem *parent, const TQString& name )
174
{
185
{
175
	FileLVI *folder = new FileLVI( parent );
186
	FileLVI *folder = new FileLVI( parent );
Lines 383-389 FileListView::item(const TQString& filename) const Link Here
383
	return 0;
394
	return 0;
384
}
395
}
385
396
386
void FileListView::addItem( const TQStringList & entries )
397
FileLVI *FileListView::addItem( const TQStringList & entries )
387
{
398
{
388
	FileLVI *flvi, *parent = findParent( entries[0] );
399
	FileLVI *flvi, *parent = findParent( entries[0] );
389
	if ( parent )
400
	if ( parent )
Lines 391-462 void FileListView::addItem( const TQStringList & entries ) Link Here
391
	else
402
	else
392
		flvi = new FileLVI( this );
403
		flvi = new FileLVI( this );
393
404
394
405
	flvi->setItemData (entries);
395
	int i = 0;
396
397
	for (TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it)
398
	{
399
		flvi->setText(i, *it);
400
		++i;
401
	}
402
406
403
	KMimeType::Ptr mimeType = KMimeType::findByPath( entries.first(), 0, true );
407
	KMimeType::Ptr mimeType = KMimeType::findByPath( entries.first(), 0, true );
404
	flvi->setPixmap( 0, mimeType->pixmap( TDEIcon::Small ) );
408
	flvi->setPixmap( 0, mimeType->pixmap( TDEIcon::Small ) );
409
410
	return flvi;
405
}
411
}
406
412
407
void FileListView::updateItem( const TQStringList &entries )
413
FileLVI *FileListView::addOrUpdateItem( const TQStringList &entries )
408
{
414
{
409
	TQStringList ancestorList = TQStringList::split( '/', entries[0] );
415
	FileLVI *flvi = item ( entries[0] );
410
416
	if (flvi) {
411
	// Checks if the listview contains the first item in the list of ancestors
417
		flvi->setItemData (entries);
412
	TQListViewItem *item = firstChild();
418
		return flvi;
413
	while ( item )
419
	} else {
414
	{
420
		return addItem (entries);
415
		if ( item->text( 0 ) == ancestorList[0] || item->text( 0 ) == ancestorList[0].stripWhiteSpace())
416
			break;
417
		item = item->nextSibling();
418
	}
419
	
420
	// If the list view does not contain the item ...
421
	if ( !item )
422
	{
423
		kdError( 1601 ) << ancestorList[0] << " not found" << endl;
424
		return;
425
	}
426
	
427
	// We've already dealt with the first item, remove it
428
	ancestorList.pop_front();
429
	
430
	while ( ancestorList.count() > 0 )
431
	{
432
		TQString name = ancestorList[0];
433
	
434
		FileLVI *parent = static_cast< FileLVI*>( item );
435
		item = parent->firstChild();
436
		while ( item )
437
		{
438
			if ( item->text(0) == name )
439
				break;
440
			item = item->nextSibling();
441
		}
442
	
443
		if ( !item )
444
		{
445
				kdError( 1601 ) << name << " not found" << endl;
446
			return;
447
		}
448
	
449
		ancestorList.pop_front();
450
	}
421
	}
451
	
452
	int i = 0;
453
	for (TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it)
454
	{
455
		item->setText(i, *it);
456
		++i;
457
	}
458
	
459
	item->setOpen( true );
460
}
422
}
461
423
462
void FileListView::selectAll()
424
void FileListView::selectAll()
Lines 481-487 void FileListView::setHeaders( const ColumnList& columns ) Link Here
481
		int colnum = addColumn( pair.first );
443
		int colnum = addColumn( pair.first );
482
		setColumnAlignment( colnum, pair.second );
444
		setColumnAlignment( colnum, pair.second );
483
	}
445
	}
484
	
446
485
	setResizeMode( TQListView::LastColumn );
447
	setResizeMode( TQListView::LastColumn );
486
448
487
	header()->show();
449
	header()->show();
(-)a/ark/filelistview.h (-5 / +9 lines)
Lines 60-65 class FileLVI : public TDEListViewItem Link Here
60
		int compare ( TQListViewItem * i, int col, bool ascending ) const;
60
		int compare ( TQListViewItem * i, int col, bool ascending ) const;
61
		virtual TQString key( int column, bool ) const;
61
		virtual TQString key( int column, bool ) const;
62
		virtual void setText( int column, const TQString &text );
62
		virtual void setText( int column, const TQString &text );
63
		/// Set the data for model entry all at once
64
		void setItemData( const TQStringList &entryData );
63
65
64
	private:
66
	private:
65
		TDEIO::filesize_t m_fileSize;
67
		TDEIO::filesize_t m_fileSize;
Lines 74-80 typedef TQValueList< TQPair< TQString, TQt::AlignmentFlags > > ColumnList; Link Here
74
class FileListView: public TDEListView
76
class FileListView: public TDEListView
75
{
77
{
76
	Q_OBJECT
78
	Q_OBJECT
77
  
79
78
	public:
80
	public:
79
		FileListView( TQWidget *parent = 0, const char* name = 0 );
81
		FileListView( TQWidget *parent = 0, const char* name = 0 );
80
82
Lines 109-123 class FileListView: public TDEListView Link Here
109
		/**
111
		/**
110
		 * Adds a file and stats to the file listing
112
		 * Adds a file and stats to the file listing
111
		 * @param entries A stringlist of the entries for each column of the list.
113
		 * @param entries A stringlist of the entries for each column of the list.
114
		 * @return The newly added FileLVI
112
		 */
115
		 */
113
		void addItem( const TQStringList& entries );
116
		FileLVI* addItem( const TQStringList& entries );
114
117
115
 		/**
118
 		/**
116
 		 * Updates a file or folder item already included in the listview 
119
		 * Adds a file and stats if it doesn't exists or updates the existing one
117
 		 * @param entries A stringlist of the updated entries for each column of the list.
120
 		 * @param entries A stringlist of the updated entries for each column of the list.
121
		 * @return The newly added or the updated FileLVI
118
 		 */
122
 		 */
119
 		void updateItem( const TQStringList& entries );
123
 		FileLVI* addOrUpdateItem( const TQStringList& entries );
120
		
124
121
		/**
125
		/**
122
		 * Returns the number of files in the archive.
126
		 * Returns the number of files in the archive.
123
		 */
127
		 */
(-)a/ark/rar.cpp (-83 / +89 lines)
Lines 25-35 Link Here
25
25
26
// Std includes
26
// Std includes
27
#include <sys/errno.h>
27
#include <sys/errno.h>
28
#include <assert.h>
28
#include <unistd.h>
29
#include <unistd.h>
29
#include <iostream>
30
#include <iostream>
30
#include <string>
31
#include <string>
31
32
32
// QT includes
33
// QT includes
34
#include <tqstring.h>
35
#include <tqregexp.h>
33
#include <tqfile.h>
36
#include <tqfile.h>
34
#include <tqdir.h>
37
#include <tqdir.h>
35
#include <tqtextcodec.h>
38
#include <tqtextcodec.h>
Lines 39-44 Link Here
39
#include <tdeglobal.h>
42
#include <tdeglobal.h>
40
#include <tdelocale.h>
43
#include <tdelocale.h>
41
#include <tdemessagebox.h>
44
#include <tdemessagebox.h>
45
#include <kmimetype.h>
42
#include <kpassdlg.h>
46
#include <kpassdlg.h>
43
#include <kprocess.h>
47
#include <kprocess.h>
44
#include <kstandarddirs.h>
48
#include <kstandarddirs.h>
Lines 83-176 RarArch::RarArch( ArkWidget *_gui, const TQString & _fileName ) Link Here
83
    verifyUncompressUtilityIsAvailable( m_unarchiver_program );
87
    verifyUncompressUtilityIsAvailable( m_unarchiver_program );
84
    setReadOnly( true );
88
    setReadOnly( true );
85
  }
89
  }
86
87
  m_headerString = "";
88
}
90
}
89
91
90
bool RarArch::processLine( const TQCString &line )
92
bool RarArch::processLine( const TQCString &line )
91
{
93
{
92
  TQString unicode_line;
94
  TQString uline = TQTextCodec::codecForLocale()->toUnicode(line);
93
95
94
  TQTextCodec *codec = TQTextCodec::codecForLocale();
96
  // Look for rar/unrar version first
95
  unicode_line = codec->toUnicode( line );
97
  if (!m_version)
96
97
	// Look for rar/unrar version first
98
	if (!m_version)
99
	{
100
		if (line.left(3) == "RAR")
101
		{
102
		  bool ok_flag = false;
103
			short version = line.mid(4, 1).toShort(&ok_flag);
104
			if (ok_flag)
105
			{
106
			  m_version = version;
107
			  if (m_version < VERSION_5)
108
			  {
109
					m_headerString = "-------------------------------------------------------------------------------";
110
					m_isFirstLine = true;
111
			  }
112
			  else
113
			  {
114
					m_headerString = "----------- ---------  -------- ----- ---------- -----  --------  ----";
115
			  }
116
			  setHeaders();
117
				return true;
118
			}
119
		}
120
		return false;
121
	}
122
	
123
  if (m_version < VERSION_5 && m_isFirstLine)
124
  {
98
  {
125
    m_entryFilename = TQString::fromLocal8Bit( line );
99
    TQRegExp versionRegExp (TQString::fromLatin1 ("RAR\\s(\\d+)\\.(\\S+)\\s.*"));
126
    m_entryFilename.remove( 0, 1 );
100
127
    m_isFirstLine = false;
101
    if (versionRegExp.exactMatch (uline))
128
    return true;
102
    {
103
      m_version = versionRegExp.capturedTexts()[1].toShort ();
104
105
      if (m_version < VERSION_5) {
106
          m_headerString = "-------------------------------------------------------------------------------";
107
          m_isFirstLine = true;
108
      } else {
109
          m_headerString = "----------- ---------  -------- ----- ---------- -----  --------  ----";
110
      }
111
      setHeaders(); //< Note: header order for version 5 is different, but keep the old one for consistency
112
      return true;
113
    }
114
    return false;
129
  }
115
  }
130
116
131
  TQStringList list;
117
  TQStringList entry;
132
  TQStringList l2 = TQStringList::split( ' ', line );
118
  TQStringList parsedData = TQStringList::split(QChar(' '), uline);
133
119
134
  if (m_version < VERSION_5)
120
  if (m_version < VERSION_5) {
121
    if (m_isFirstLine)
122
    {
123
      m_entryFilename = uline.remove( 0, 1 );
124
      m_isFirstLine = false;
125
      return true;
126
    }
127
128
    if (parsedData.size() < 9) {
129
      kdError ( 1601 ) << "Failed to parse rar<5 output string: \"" << uline << "\"" << endl;
130
    }
131
132
    entry << m_entryFilename; // filename
133
    entry << parsedData[ 0 ]; // size
134
    entry << parsedData[ 1 ]; // packed
135
    entry << parsedData[ 2 ]; // ratio
136
137
    TQStringList date =  TQStringList::split( '-', parsedData[ 3 ] );
138
    entry << ArkUtils::fixYear( date[ 2 ].latin1() ) + '-' + date[ 1 ] + '-' + date [ 0 ] + ' ' + parsedData[4]; // date
139
    entry << parsedData[ 5 ]; // attributes
140
    entry << parsedData[ 6 ]; // crc
141
    entry << parsedData[ 7 ]; // method
142
    entry << parsedData[ 8 ]; // Version
143
144
    m_isFirstLine = true;
145
  }
146
  else
135
  {
147
  {
136
		list << m_entryFilename; // filename
148
    // Note: don't use parsedData for names due to they may contain trailing spaces
137
		list << l2[ 0 ]; // size
149
    TQRegExp nameRegExp (TQString::fromLatin1 ("\\s*(\\S+\\s+){6}\\S+  (.*)"));
138
		list << l2[ 1 ]; // packed
150
139
		list << l2[ 2 ]; // ratio
151
    if (parsedData.size() >= 8 && nameRegExp.exactMatch (uline)) {
140
	
152
      m_entryFilename = nameRegExp.capturedTexts()[2];
141
		TQStringList date =  TQStringList::split( '-', l2[ 3 ] );
153
142
		list << ArkUtils::fixYear( date[ 2 ].latin1() ) + '-' + date[ 1 ] + '-' + date [ 0 ] + ' ' + l2[4]; // date
154
      entry << m_entryFilename; // filename
143
		list << l2[ 5 ]; // attributes
155
      entry << parsedData[ 1 ]; // size
144
		list << l2[ 6 ]; // crc
156
      entry << parsedData[ 2 ]; // packed
145
		list << l2[ 7 ]; // method
157
      entry << parsedData[ 3 ]; // ratio
146
		list << l2[ 8 ]; // Version
158
147
159
      entry << parsedData[ 4 ] + " " + parsedData[ 5 ]; // date and time
148
		m_isFirstLine = true;
160
      entry << parsedData[ 0 ]; // attributes
149
	}
161
      entry << parsedData[ 6 ]; // crc
150
	else
162
    } else {
151
	{
163
      kdError ( 1601 ) << "Failed to parse rar-5+ output string: \"" << uline << "\"" << endl;
152
		m_entryFilename = line.mid(line.find(l2[7]));
164
      return false;
153
		list << m_entryFilename; // filename
165
    }
154
		list << l2[ 1 ]; // size
166
  }
155
		list << l2[ 2 ]; // packed
167
  
156
		list << l2[ 3 ]; // ratio
168
  // send to GUI
157
	
169
  // Use addOrUpdateItem() rather than addItem() due to recent RAR version
158
		TQStringList date =  TQStringList::split('-', l2[4]);
170
  // place directories in archive after their content.
159
		list << l2[ 4 ] + " " + l2[ 5 ]; // date and time
171
  FileLVI *item = m_gui->fileList()->addOrUpdateItem( entry );
160
		list << l2[ 0 ]; // attributes
172
  
161
		list << l2[ 6 ]; // crc
173
  // But archives packaged with older versions of ark may have directories 
162
	}
174
  // entries first, so make sure they will get apropriate icon
163
	// send to GUI
175
  if (entry[5].find('d', 0, /*cs=*/ false) != -1) {
164
	if ( l2[6] == "00000000" )
176
    // check attr's for d (case insansitive to handle windows archives)
165
	{
177
    assert (item);
166
		// folders have CRC equal to 00000000
178
    item->setPixmap( 0, KMimeType::mimeType( "inode/directory" )->pixmap( TDEIcon::Small ) );
167
		// RAR utilities show the folders at the end of the listing so the folders
179
  }
168
		// have been already added to the listview at this point without specifying
180
169
		// all the columns but the name. Update the item with the missing info
170
		m_gui->fileList()->updateItem( list );
171
	}
172
	else
173
		m_gui->fileList()->addItem( list );
174
  return true;
181
  return true;
175
}
182
}
176
183
Lines 216-224 void RarArch::setHeaders() Link Here
216
  list.append( CRC_COLUMN );
223
  list.append( CRC_COLUMN );
217
  if (m_version < VERSION_5)
224
  if (m_version < VERSION_5)
218
  {
225
  {
219
		list.append( METHOD_COLUMN );
226
    list.append( METHOD_COLUMN );
220
		list.append( VERSION_COLUMN );
227
    list.append( VERSION_COLUMN );
221
	}
228
  }
222
  emit headers( list );
229
  emit headers( list );
223
}
230
}
224
231
225
- 

Return to bug 2644