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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
/* ============================================================
* File : gallerylist.cpp
* Author: Colin Guthrie <kde@colin.guthr.ie>
* Date : 2006-09-04
* Copyright 2006 by Colin Guthrie <kde@colin.guthr.ie>
*
* 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, or (at your option)
* 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.
*
* ============================================================ */
// Include files for TQt
#include <tqlistview.h>
#include <tqpushbutton.h>
#include <tqtimer.h>
#include <tqpixmap.h>
#include <tqcursor.h>
#include <tqlineedit.h>
#include <tqprogressdialog.h>
#include <tqspinbox.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
// Include files for KDE
#include <klocale.h>
#include <kmessagebox.h>
#include <kapplication.h>
#include <kiconloader.h>
// Local includes.
#include "galleries.h"
#include "gallerylist.h"
#include "galleryconfig.h"
namespace KIPIGalleryExportPlugin
{
GalleryList::GalleryList(TQWidget *pParent, Galleries* pGalleries, bool blnShowOpen)
: KDialogBase(pParent, 0, true, i18n("Remote Galleries"),
Ok|Close|User1|User2|User3,
Close, false),
mpGalleries(pGalleries),
mpCurrentGallery(0)
{
if (!blnShowOpen)
showButtonOK(false);
setButtonGuiItem(User3, KStdGuiItem::add());
setButtonGuiItem(User2, KStdGuiItem::configure());
setButtonGuiItem(User1, KStdGuiItem::remove());
setButtonGuiItem(Close, KStdGuiItem::close());
setButtonGuiItem(Ok, KStdGuiItem::open());
enableButton(Ok, false);
enableButton(User1, false);
enableButton(User2, false);
TQFrame *page = new TQFrame(this);
TQHBoxLayout *tll = new TQHBoxLayout(page);
page->setMinimumSize(400, 200);
setMainWidget(page);
TQHBoxLayout *hb = new TQHBoxLayout();
hb->setSpacing(KDialog::spacingHint());
tll->addItem(hb);
TQLabel *label = new TQLabel(page);
hb->addWidget(label);
label->setPixmap(UserIcon("gallery"));
label->setFrameStyle (TQFrame::Panel | TQFrame::Sunken);
label->setAlignment(TQt::AlignTop);
TQVBoxLayout *vb = new TQVBoxLayout();
vb->setSpacing (KDialog::spacingHint());
tll->addItem(vb);
mpGalleryList = mpGalleries->asTQListView(page);
vb->addWidget(mpGalleryList);
connect(mpGalleryList, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(selectionChanged()));
connect(mpGalleryList, TQT_SIGNAL(doubleClicked(TQListViewItem*, const TQPoint&, int)),
this, TQT_SLOT(doubleClicked(TQListViewItem*, const TQPoint&, int)));
}
GalleryList::~GalleryList()
{
}
Gallery* GalleryList::GetGallery()
{
return mpCurrentGallery;
}
void GalleryList::selectionChanged()
{
TQListViewItem* p_lvi = mpGalleryList->selectedItem();
bool bln_selected = (p_lvi ? true : false);
enableButton(User1, bln_selected);
enableButton(User2, bln_selected);
enableButton(Ok, bln_selected);
if (bln_selected)
{
GalleryTQListViewItem* p_glvi = dynamic_cast<GalleryTQListViewItem*>(p_lvi);
mpCurrentGallery = p_glvi->GetGallery();
}
else
{
mpCurrentGallery = 0;
}
}
void GalleryList::doubleClicked(TQListViewItem* pCurrent, const TQPoint&, int)
{
if (!pCurrent)
return;
if (actionButton(Ok)->isVisible())
{
accept();
}
else
{
slotUser2();
}
}
//================== Add =====
void GalleryList::slotUser3(void)
{
Gallery* p_gallery = new Gallery();
GalleryEdit dlg(this, p_gallery, i18n("New Remote Gallery"));
if (TQDialog::Accepted == dlg.exec())
{
mpGalleries->Add(p_gallery);
mpGalleries->Save();
p_gallery->asTQListViewItem(mpGalleryList);
}
else
{
delete p_gallery;
}
}
//================== Edit ======
void GalleryList::slotUser2(void)
{
TQListViewItem* p_lvi = mpGalleryList->selectedItem();
if (!p_lvi)
{
KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), i18n("No gallery selected!"));
}
else
{
GalleryTQListViewItem* p_glvi = dynamic_cast<GalleryTQListViewItem*>(p_lvi);
GalleryEdit dlg(this, p_glvi->GetGallery(), i18n("Edit Remote Gallery"));
if (TQDialog::Accepted == dlg.exec())
{
p_glvi->Refresh();
mpGalleries->Save();
}
}
}
//================== Remove ======
void GalleryList::slotUser1(void)
{
TQListViewItem* p_lvi = mpGalleryList->selectedItem();
if (!p_lvi)
{
KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), i18n("No gallery selected!"));
}
else
{
if (KMessageBox::Yes ==
KMessageBox::warningYesNo(TQT_TQWIDGET(kapp->activeWindow()),
i18n("Are you sure you want to remove this gallery? "
"All synchronisaton settings will be lost. "
"You cannot undo this action."),
i18n("Remove Remote Gallery"),
KStdGuiItem::yes(), KStdGuiItem::no(),
TQString(), KMessageBox::Dangerous))
{
GalleryTQListViewItem* p_glvi = dynamic_cast<GalleryTQListViewItem*>(p_lvi);
Gallery* p_gallery = p_glvi->GetGallery();
delete p_glvi;
mpGalleries->Remove(p_gallery);
mpGalleries->Save();
}
}
}
}
#include "gallerylist.moc"
|