1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/* This file is part of the KDE project
Copyright (C) 2000 - 2008 David Faure <faure@kde.org>
Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
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 ) version 3 or, at the discretion of KDE e.V. ( which shall
act as a proxy as in section 14 of the GPLv3 ), any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef FILETYPESVIEW_H
#define FILETYPESVIEW_H
#include <QList>
#include <QMap>
#include <QLabel>
#include <QStackedWidget>
#include <KSharedConfig>
#include <KCModule>
#include "typeslistitem.h"
class QLabel;
class QTreeWidget;
class QTreeWidgetItem;
class QPushButton;
class KLineEdit;
class FileTypeDetails;
class FileGroupDetails;
class QStackedWidget;
class FileTypesView : public KCModule
{
Q_OBJECT
public:
FileTypesView(QWidget *parent, const QVariantList &args);
~FileTypesView() override;
void load() override;
void save() override;
void defaults() override;
protected Q_SLOTS:
void addType();
void removeType();
void updateDisplay(QTreeWidgetItem *);
void slotDoubleClicked(QTreeWidgetItem *);
void slotFilter(const QString &patternFilter);
void setDirty(bool state);
void slotDatabaseChanged(const QStringList& changedResources);
void slotEmbedMajor(const QString &major, bool &embed);
private:
void readFileTypes();
void updateRemoveButton(TypesListItem* item);
private:
QTreeWidget *typesLV;
QPushButton *m_removeTypeB;
QStackedWidget * m_widgetStack;
FileTypeDetails * m_details;
FileGroupDetails * m_groupDetails;
QLabel * m_emptyWidget;
KLineEdit *patternFilterLE;
QStringList removedList;
bool m_dirty;
bool m_removeButtonSaysRevert;
QMap<QString,TypesListItem*> m_majorMap; // groups
QList<TypesListItem *> m_itemList;
KSharedConfig::Ptr m_fileTypesConfig;
};
// helper class for loading the icon on request instead of preloading lots of probably
// unused icons which takes quite a lot of time
class TypesListTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
explicit TypesListTreeWidget(QWidget *parent)
: QTreeWidget(parent) {
}
protected:
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
static_cast<TypesListItem *>(itemFromIndex(index))->loadIcon();
QTreeWidget::drawRow(painter, option, index);
}
};
#endif
|