1 
2 
3 #ifndef FILELIST_H
4 #define FILELIST_H
5 
6 #include <QTreeWidget>
7 #include "filelistitem.h"
8 
9 #include <QTime>
10 // #include <QDebug>
11 
12 class FileListItem;
13 class Config;
14 class Logger;
15 class TagEngine;
16 class OptionsEditor;
17 class OptionsLayer;
18 class ConversionOptions;
19 
20 class QMenu;
21 class KAction;
22 class QProgressBar;
23 
24 /**
25  * @short The file list
26  * @author Daniel Faust <hessijames@gmail.com>
27  * @version 0.3
28  */
29 class FileList : public QTreeWidget
30 {
31     Q_OBJECT
32 public:
33     enum Columns {
34         Column_State    = 0,
35         Column_Input    = 1,
36         Column_Output   = 2,
37         Column_Quality  = 3
38     };
39 
40     /** Constructor */
41     FileList( Logger *_logger, Config *_config, QWidget *parent );
42 
43     /** Destructor */
44     ~FileList();
45 
topLevelItem(int index)46     FileListItem *topLevelItem( int index ) const { return static_cast<FileListItem*>( QTreeWidget::topLevelItem(index) ); }
47 
setOptionsLayer(OptionsLayer * _optionsLayer)48     void setOptionsLayer( OptionsLayer *_optionsLayer ) { optionsLayer = _optionsLayer; }
49 
50     void load( bool user = false );
51     void load( const QString& fileListPath );
52     void updateAllItems(); // Gets triggered if the configuration changes and the file list needs to be updated
53     void updateItem( FileListItem *item );
54 
55     bool waitForAlbumGain( FileListItem *item );
56 
57 private:
58     /** Counts all files in a directory */
59     int countDir( const QString& directory, bool recursive, int count = 0 );
60     /** Lists all files in a directory and adds them to the file list */
61     int listDir( const QString& directory, const QStringList& filter, bool recursive, int conversionOptionsId, int count = 0 );
62     /** A progressbar, that is shown, when a directory is added recursive */
63     QProgressBar *pScanStatus;
64     /** Update timer for the scan status */
65     QTime tScanStatus;
66 
67 // debug
68 //     int TimeCount;
69 //     QTime Time;
70 
71     void convertNextItem();
72     int waitingCount();
73     int convertingCount( bool includeWaiting = false );
74 
75 //     qulonglong spaceLeftForDirectory( const QString& dir );
76 //     QStringList fullDiscs; // a list of mount points with volumes that don't have enougth space left
77 
78     QList<FileListItem*> selectedFiles;
79 
80     void dragEnterEvent( QDragEnterEvent *event );
81     void dropEvent( QDropEvent *event );
82 
83     void resizeEvent( QResizeEvent *event );
84 
85     bool queue;
86 
87     Logger *logger;
88     Config *config;
89     TagEngine *tagEngine;
90     OptionsEditor *optionsEditor;
91     OptionsLayer *optionsLayer;
92 
93     QMenu *contextMenu;
94     KAction *editAction;
95     KAction *startAction;
96     KAction *stopAction;
97     KAction *removeAction;
98 //     KAction* paste;
99 
100 private slots:
101     void showContextMenu( const QPoint& point );
102     void showOptionsEditorDialog();
103     void removeSelectedItems();
104     void convertSelectedItems();
105     void killSelectedItems();
106     void itemsSelected();
107 
108     // connected to OptionsEditor
109     void updateItems( QList<FileListItem*> items );
110     void selectPreviousItem();
111     void selectNextItem();
112 
113     void showLogClicked( const QString& logIdString );
114 
115 public slots:
116     // connected to soundKonverterView
117     void addFiles( const QList<QUrl>& fileList, ConversionOptions *conversionOptions, const QString& notifyCommand = "", const QString& _codecName = "", int conversionOptionsId = -1 );
118     void addDir( const QUrl& directory, bool recursive, const QStringList& codecList, ConversionOptions *conversionOptions );
119     void addTracks( const QString& device, QList<int> trackList, int tracks, QList<TagData*> tagList, ConversionOptions *conversionOptions, const QString& notifyCommand = "" );
120     void startConversion();
121     void killConversion();
122     void stopConversion();
123     void continueConversion();
124 
125     void save( bool user = false );
126 
127     // connected to Convert
128     /** The conversion of an item has finished and the state is reported */
129     void itemFinished( FileListItem *item, FileListItem::ReturnCode returnCode, bool waitingForAlbumGain = false );
130     /** The ripping of a track has finished, so the device is free for ripping the next track */
131     void rippingFinished( const QString& device );
132 
133 signals:
134     // connected to ProgressIndicator
135     void timeChanged( float timeDelta );
136     void finished( bool );
137     // connected to soundKonverterView
138     void fileCountChanged( int count );
139     void conversionStarted();
140     void conversionStopped( bool failed );
141     void queueModeChanged( bool enabled );
142     void showLog( const int logId );
143 
144 //     void stopClicked();
145 //     void continueClicked();
146 
147     // connected to Convert
148     void convertItem( FileListItem* );
149     void killItem( FileListItem* );
150     void replaygainItems( QList<FileListItem*> );
151 
152     // connected to OptionsEditor
153     void editItems( QList<FileListItem*> );
154     void setPreviousItemEnabled( bool );
155     void setNextItemEnabled( bool );
156     void itemRemoved( FileListItem* );
157 };
158 
159 #endif // FILELIST_H
160