not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / kfontinst / kcmfontinst / DuplicatesDialog.h
blob9df5f123c8fb90a522bdec5f75f579bc117f787e
1 #ifndef __DUPLICATES_DIALOG_H__
2 #define __DUPLICATES_DIALOG_H__
4 /*
5 * KFontInst - KDE Font Installer
7 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
9 * ----
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
27 #include <QtGui/QPixmap>
28 #include <QtCore/QThread>
29 #include <QtGui/QTreeWidget>
30 #include "ActionDialog.h"
31 #include "Misc.h"
33 class QLabel;
34 class QMenu;
35 class QAction;
37 namespace KFI
40 class CJobRunner;
41 class CFontList;
42 class CDuplicatesDialog;
44 class CFontFileList : public QThread
46 Q_OBJECT
48 public:
50 typedef QHash<Misc::TFont, QStringList> TFontMap;
53 // TFile store link from filename to FontMap item.
54 // This is used when looking for duplicate filenames (a.ttf/a.TTF).
55 struct TFile
57 TFile(const QString &n, CFontFileList::TFontMap::Iterator i) : name(n), it(i), userLower(false) { }
58 TFile(const QString &n, bool l=false) : name(n), userLower(l) { }
60 bool operator==(const TFile &f) const
62 return userLower||f.userLower
63 ? name.toLower()==f.name.toLower()
64 : name==f.name;
67 QString name;
68 CFontFileList::TFontMap::Iterator it;
69 bool userLower;
72 public:
74 CFontFileList(CDuplicatesDialog *parent);
76 void start();
77 void terminate();
78 void getDuplicateFonts(TFontMap &map);
79 bool wasTerminated() const { return itsTerminated; }
81 Q_SIGNALS:
83 void finished();
85 private:
87 void run();
88 void fileDuplicates(const QString &folder, const QSet<TFile> &files);
90 private:
92 bool itsTerminated;
93 TFontMap itsMap;
96 class CFontFileListView : public QTreeWidget
98 Q_OBJECT
100 public:
102 CFontFileListView(QWidget *parent);
103 virtual ~CFontFileListView() { }
105 QSet<QString> getMarkedFiles();
106 void removeFiles(const QSet<QString> &files);
108 Q_SIGNALS:
110 void haveDeletions(bool have);
112 private Q_SLOTS:
114 void openViewer();
115 void properties();
116 void mark();
117 void unmark();
118 void selectionChanged();
119 void clicked(QTreeWidgetItem *item, int col);
120 void contextMenuEvent(QContextMenuEvent *ev);
122 private:
124 void checkFiles();
126 private:
128 QMenu *itsMenu;
129 QAction *itsMarkAct,
130 *itsUnMarkAct;
133 class CDuplicatesDialog : public CActionDialog
135 Q_OBJECT
137 public:
139 CDuplicatesDialog(QWidget *parent, CJobRunner *jr, CFontList *fl);
141 int exec();
142 bool modifiedSys() const { return itsModifiedSys; }
143 bool modifiedUser() const { return itsModifiedUser; }
145 const CFontList * fontList() const { return itsFontList; }
147 private Q_SLOTS:
149 void scanFinished();
150 void slotButtonClicked(int button);
152 private:
154 int deleteFiles();
155 QSet<QString> deleteFiles(const QSet<QString> &files);
156 QSet<QString> deleteSysFiles(const QStringList &files);
158 private:
160 bool itsModifiedSys,
161 itsModifiedUser;
162 CFontFileList *itsFontFileList;
163 QLabel *itsLabel;
164 CFontFileListView *itsView;
165 CJobRunner *itsRunner;
166 CFontList *itsFontList;
171 #endif