1 /***************************************************************************
2 *                                                                         *
3 *   This program is free software; you can redistribute it and/or modify  *
4 *   it under the terms of the GNU General Public License as published by  *
5 *   the Free Software Foundation; either version 3 of the License, or     *
6 *   (at your option) any later version.                                   *
7 *                                                                         *
8 ***************************************************************************/
9 
10 #pragma once
11 
12 #include <QWidget>
13 #include <QMap>
14 #include <QCloseEvent>
15 
16 #include "ui_UIADLSearch.h"
17 #include "ui_UIADLSearchEditor.h"
18 #include "ArenaWidget.h"
19 #include "WulforUtil.h"
20 #include <dcpp/stdinc.h>
21 #include <dcpp/ADLSearch.h>
22 #include <dcpp/Singleton.h>
23 
24 class ADLSModel;
25 class ADLSItem;
26 
27 using namespace dcpp;
28 
29 class ADLSEditor:
30         public QDialog,
31         public Ui::UIADLSEditor
32 {
33     public:
34         ADLSEditor(QWidget *parent = NULL):
QDialog(parent)35                 QDialog(parent)
36         {
37             setupUi(this);
38 
39             setFixedSize(sizeHint());
40         }
41 };
42 
43 class ADLS :
44         public QWidget,
45         private Ui::UIADLS,
46         public ArenaWidget,
47         public dcpp::Singleton<ADLS>
48 {
49     Q_OBJECT
50     Q_INTERFACES(ArenaWidget)
51 
52     friend class dcpp::Singleton<ADLS>;
53 
54     typedef QMap<QString,QVariant> StrMap;
55 public:
56     QWidget *getWidget();
57     QString getArenaTitle();
58     QString getArenaShortTitle();
59     QMenu *getMenu();
getPixmap()60     const QPixmap &getPixmap(){ return WICON(WulforUtil::eiADLS); }
role()61     ArenaWidget::Role role() const { return ArenaWidget::ADLS; }
62 
63 protected:
64     virtual void closeEvent(QCloseEvent *);
65 
66 private Q_SLOTS:
67     void slotContexMenu(const QPoint&);
68     void slotClicked(const QModelIndex&);
69     void slotDblClicked();
70     void slotHeaderMenu();
71 
72     void slotSettingsChanged(const QString &key, const QString &value);
73 
74     void slotAdd_newButtonClicked();
75     void slotChangeButtonClicked();
76     void slotRemoveButtonClicked();
77     void slotUpButtonClicked();
78     void slotDownButtonClicked();
79 
80 private:
81     typedef ADLSearchManager::SearchCollection::size_type VectorSize;
82     ADLS(QWidget* = NULL);
83     virtual ~ADLS();
84 
85     void load();
86     void save();
87 
88     void init();
89     void initEditor(ADLSEditor &);
90     void initEditor(ADLSEditor &, StrMap&);
91     /** Init StrMap for importing into the ADLSEditor */
92     void getParams(/*const*/ ADLSearch&, StrMap&);
93     /** Init StrMap for importing into the ADLSearchManager::SearchCollection */
94     void getParams(const ADLSEditor&, StrMap&);
95     void updateEntry(ADLSearch&, StrMap&);
96     void updateItem(ADLSItem*, StrMap&);
97     void addItem(ADLSearch &);
98     QString SizeTypeToString(ADLSearch::SizeType);
99     QString SourceTypeToString(ADLSearch::SourceType);
100     ADLSItem *getItem();
101     /*VectorSize*/int findEntry(StrMap&);
102     ADLSModel *model;
103 
104 };
105