/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #ifndef SERIESTREEWIDGET_H #define SERIESTREEWIDGET_H #include #include #include #include class QLineEdit; class QPushButton; class QSortFilterProxyModel; class QComboBox; class QEvent; class QLabel; class SeriesTreeModel; class SeriesTreeView; class SeriesTreeSortModel; class HoverWindow; class FilesTreeModel; class AddCoverDialog; class HoverWindow; class SeriesTreeWidget : public QWidget { Q_OBJECT public: explicit SeriesTreeWidget(QWidget *parent = 0); SeriesTreeView *seriesTree() { return mView; } SeriesTreeSortModel *seriesProxy() { return mProxy; } public slots: void newSeries(); void seriesAdded(const QString seriesName, int seriesPart, bool resort = true); void deleteFromSeries(); void readSettings(); void writeSettings(); void expandCurrent(); void addCover(); private slots: void filter(); void clearFilter(); void resort(); void itemExpanded(const QModelIndex &); void itemCollaped(const QModelIndex &); void expandItems(const QStringList &items); void editItem(); signals: void filesReload(); private: QLineEdit *mFilterEdit; QPushButton *mFilter; QPushButton *mClear; SeriesTreeView *mView; SeriesTreeSortModel *mProxy; SeriesTreeModel *mModel; AddCoverDialog *mCoverDialog; QStringList mExpandedItems; }; class SeriesTreeView : public QTreeView { Q_OBJECT public: explicit SeriesTreeView(QWidget *parent = 0); public slots: void readConfig(); protected: virtual void contextMenuEvent(QContextMenuEvent *e); virtual bool event(QEvent *event); private: bool exitHover(bool exitVal = true); QStringList children(const QModelIndex &idx) const; QModelIndex mCurHover; HoverWindow *mHoverWin; bool mHover; }; class SeriesTreeSortModel : public QSortFilterProxyModel { Q_OBJECT public: SeriesTreeSortModel(QObject *parent = 0); ~SeriesTreeSortModel() {} protected: virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; }; class AddCoverDialog : public QDialog { Q_OBJECT public: explicit AddCoverDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); const QString file() const; int fileType() const { return mCurrentType; } private slots: void selectFile(); void typeChanged(const QString &type); private: QLineEdit *mFile; QComboBox *mFileType; QPushButton *mSelectFile; QPushButton *mOk; QPushButton *mCancel; QString mLastOpenedDir; int mCurrentType; FilesTreeModel *mFilesModel; }; #endif