1 #ifndef __DUPLICATES_DIALOG_H__
2 #define __DUPLICATES_DIALOG_H__
5 * KFontInst - KDE Font Installer
7 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
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"
42 class CDuplicatesDialog
;
44 class CFontFileList
: public QThread
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).
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()
68 CFontFileList::TFontMap::Iterator it
;
74 CFontFileList(CDuplicatesDialog
*parent
);
78 void getDuplicateFonts(TFontMap
&map
);
79 bool wasTerminated() const { return itsTerminated
; }
88 void fileDuplicates(const QString
&folder
, const QSet
<TFile
> &files
);
96 class CFontFileListView
: public QTreeWidget
102 CFontFileListView(QWidget
*parent
);
103 virtual ~CFontFileListView() { }
105 QSet
<QString
> getMarkedFiles();
106 void removeFiles(const QSet
<QString
> &files
);
110 void haveDeletions(bool have
);
118 void selectionChanged();
119 void clicked(QTreeWidgetItem
*item
, int col
);
120 void contextMenuEvent(QContextMenuEvent
*ev
);
133 class CDuplicatesDialog
: public CActionDialog
139 CDuplicatesDialog(QWidget
*parent
, CJobRunner
*jr
, CFontList
*fl
);
142 bool modifiedSys() const { return itsModifiedSys
; }
143 bool modifiedUser() const { return itsModifiedUser
; }
145 const CFontList
* fontList() const { return itsFontList
; }
150 void slotButtonClicked(int button
);
155 QSet
<QString
> deleteFiles(const QSet
<QString
> &files
);
156 QSet
<QString
> deleteSysFiles(const QStringList
&files
);
162 CFontFileList
*itsFontFileList
;
164 CFontFileListView
*itsView
;
165 CJobRunner
*itsRunner
;
166 CFontList
*itsFontList
;