51 #include <OpenFlipper/common/RendererInfo.hh> 54 #if QT_VERSION >= 0x050000 60 #include "postProcessorWidget.hh" 63 PostProcessorDialog::PostProcessorDialog(QWidget *_parent)
68 list->setContextMenuPolicy(Qt::CustomContextMenu);
69 activeList->setContextMenuPolicy(Qt::CustomContextMenu);
71 connect(closeButton, SIGNAL(clicked()),
this, SLOT(accept()));
72 connect(list,SIGNAL(customContextMenuRequested(
const QPoint&)),
this,SLOT(slotContextMenuActivate(
const QPoint&)));
73 connect(activeList,SIGNAL(customContextMenuRequested(
const QPoint&)),
this,SLOT(slotContextMenuDeactivate(
const QPoint&)));
74 connect(activateButton,SIGNAL(clicked()),
this,SLOT(slotActivatePostProcessor()));
75 connect(deactivateButton,SIGNAL(clicked()),
this,SLOT(slotDeactivatePostProcessor()));
76 connect(upButton,SIGNAL(clicked()),
this,SLOT(slotMoveUp()));
77 connect(downButton,SIGNAL(clicked()),
this,SLOT(slotMoveDown()));
78 connect(saveButton,SIGNAL(clicked()),
this,SLOT(slotSaveActive()));
79 connect(refreshButton,SIGNAL(clicked()),
this,SLOT(refresh()));
82 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
84 closeButton->setIcon( QIcon(iconPath +
"window-close.png"));
85 saveButton->setIcon( QIcon(iconPath +
"document-save.png"));
86 refreshButton->setIcon( QIcon(iconPath +
"edit-redo.png"));
90 void PostProcessorDialog::closeEvent(QCloseEvent *_event)
96 void PostProcessorDialog::showEvent ( QShowEvent * )
106 activeRowToRow_.clear();
109 for (
int i = 0; i < postProcessorManager().
numActive(currentExaminer_); ++i)
111 unsigned int id = postProcessorManager().
activeId(currentExaminer_, i);
112 activeRowToRow_.push_back(
id);
114 QListWidgetItem *activeItem =
new QListWidgetItem(
"");
115 activeList->addItem(activeItem);
116 QFrame* frame = createFrame(*postProcessorManager()[
id]);
117 activeItem->setSizeHint(frame->sizeHint());
118 activeList->setItemWidget(activeItem,frame);
122 for (
unsigned int i = 0 ; i < postProcessorManager().
available() ; ++i)
130 QFrame* frame = createFrame(*processor);
132 QListWidgetItem *item =
new QListWidgetItem(
"");
133 item->setSizeHint( frame->sizeHint() );
137 list->setItemWidget(item, frame);
141 for (std::vector<unsigned>::iterator iter = activeRowToRow_.begin(); iter != activeRowToRow_.end() && !found; ++iter)
142 found = (*iter == i);
144 list->setRowHidden(list->row(item),
true);
151 QList<QListWidgetItem*> selectedItems = list->selectedItems();
153 for (
int i=0; i < selectedItems.size(); ++i)
155 QListWidgetItem* item = selectedItems[i];
156 const int currentRow = list->row( item );
158 postProcessorManager().
append( currentRow, currentExaminer_);
161 item->setHidden(
true);
162 item->setSelected(
false);
165 QListWidgetItem *activeItem =
new QListWidgetItem(
"");
166 activeList->addItem(activeItem);
167 activeItem->setSelected(
true);
169 QFrame* frame = createFrame(*postProcessorManager()[currentRow]);
170 activeItem->setSizeHint( frame->sizeHint() );
171 activeList->setItemWidget(activeItem,frame);
172 activeRowToRow_.push_back(currentRow);
175 emit updateExaminer(currentExaminer_);
181 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
183 for (
int i=0; i < selectedItems.size(); ++i)
185 QListWidgetItem* activeItem = selectedItems[i];
187 const unsigned chainPos = activeList->row(activeItem);
188 const unsigned activeID = activeRowToRow_[chainPos];
189 QListWidgetItem* item = list->item(activeID);
192 postProcessorManager().
remove(currentExaminer_, chainPos);
195 item->setHidden(
false);
196 item->setSelected(
true);
200 for (
unsigned i = chainPos; i < activeRowToRow_.size()-1; ++i)
201 activeRowToRow_[i] = activeRowToRow_[i+1];
204 activeItem = activeList->takeItem(activeList->row(activeItem));
207 activeRowToRow_.erase( activeRowToRow_.end()-selectedItems.size(), activeRowToRow_.end());
209 emit updateExaminer(currentExaminer_);
215 if (_from >= static_cast<unsigned>(activeList->count()))
218 if (_to >= static_cast<unsigned>(activeList->count()))
219 _to = activeList->count()-1;
225 QListWidgetItem* activeItem = activeList->takeItem(_from);
226 activeList->insertItem(_to,activeItem);
227 QFrame* frame = createFrame(*postProcessorManager()[activeRowToRow_[_from]]);
228 activeItem->setSizeHint(frame->sizeHint());
229 activeList->setItemWidget(activeItem,frame);
230 activeList->setItemSelected(activeItem,
true);
233 const int chainPos = _from;
234 const int activeID = activeRowToRow_[_from];
235 postProcessorManager().
remove(currentExaminer_, chainPos);
236 postProcessorManager().
insert(activeID,_to,currentExaminer_);
239 int inc = (_from > _to)? -1: +1;
240 for(
unsigned int currentRow = _from;currentRow != _to; currentRow += inc)
241 std::swap(activeRowToRow_[currentRow+inc],activeRowToRow_[currentRow]);
243 emit updateExaminer(currentExaminer_);
252 QMenu *menu =
new QMenu(list);
255 action = menu->addAction(tr(
"Activate"));
256 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(slotActivatePostProcessor()));
258 menu->exec(list->mapToGlobal(_point),0);
264 if (!activeList->count())
267 QMenu *menu =
new QMenu(activeList);
270 action = menu->addAction(tr(
"Up"));
271 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(slotMoveUp()));
272 action = menu->addAction(tr(
"Down"));
273 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(slotMoveDown()));
274 action = menu->addAction(tr(
"Deactivate"));
275 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(slotDeactivatePostProcessor()));
277 menu->exec(activeList->mapToGlobal(_point),0);
283 QFrame* frame =
new QFrame();
284 QHBoxLayout* hlayout =
new QHBoxLayout;
286 QLabel* name =
new QLabel( _pPI.
name );
289 font.setPointSize(10);
291 QLabel* version =
new QLabel( _pPI.
version );
292 QPushButton* optionsButton =
new QPushButton(
"Options");
293 hlayout->addWidget(name);
294 hlayout->addStretch();
295 hlayout->addWidget(version);
297 optionsButton->setEnabled(
false);
300 optionsButton->setEnabled(
true);
301 connect(optionsButton,SIGNAL(clicked()),_pPI.
optionsAction,SLOT(trigger()));
304 QVBoxLayout* vlayout =
new QVBoxLayout;
306 QLabel* description =
new QLabel( _pPI.
description );
308 vlayout->addLayout(hlayout,20);
310 QHBoxLayout* optionsLayout =
new QHBoxLayout();
311 vlayout->addLayout(optionsLayout);
312 optionsLayout->addWidget(description);
313 optionsLayout->addStretch();
314 optionsLayout->addWidget(optionsButton);
316 frame->setLayout(vlayout);
324 template<
typename TCmp>
330 bool operator()(QListWidgetItem* left, QListWidgetItem* right)
332 return TCmp()(list_->row(left) , list_->row(right));
339 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
346 for(
int i=0; i < selectedItems.size() && activeList->row(selectedItems[i]) == activeList->count()-1-i;++i)
350 for (
int i=selectedItems.size()-1+start; i >= 0 ; --i)
352 QListWidgetItem* activeItem = activeList->selectedItems()[i];
353 unsigned selectedRow = activeList->row(activeItem);
354 slotMovePostProcessor(selectedRow,selectedRow+1);
362 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
369 for(
int i=0; i < selectedItems.size() && activeList->row(selectedItems[i]) == i;++i)
373 for (
int i=start; i < selectedItems.size(); ++i)
375 QListWidgetItem* activeItem = selectedItems[i];
376 unsigned selectedRow = activeList->row(activeItem);
377 slotMovePostProcessor(selectedRow,selectedRow-1);
383 QStringList activeList(
"");
385 for (
int i = 0; i < postProcessorManager().
numActive(currentExaminer_); ++i)
387 unsigned int id = postProcessorManager().
activeId(currentExaminer_, i);
388 activeList.push_back(postProcessorManager()[
id]->name);
396 return OpenFlipperSettings().
value(QString(
"PostProcessor/Viewer/%1").arg(_examiner),QStringList(
"")).toStringList();
401 QStringList active = getSavedPostProcessorNames(_examiner);
402 for (QStringList::iterator iter = active.begin(); iter != active.end(); ++iter)
404 postProcessorManager().
append(*iter,_examiner);
void slotMoveDown()
move the selected active postprocessor 1 down
void initWindow()
initiaize the window with the post processors of the current examiner
static void loadSavedPostProcessors(const unsigned _examiner)
append all saved post processors
QAction * optionsAction
Possible action to add an options action or menu to the system.
void insert(unsigned int _active, int _chainIdx, int _viewerId)
Insert the active post processor to the chain for viewer.
unsigned int available()
number of available post processor
void slotMovePostProcessor(unsigned _from, unsigned _to)
Move the position/ordering of postprocessor in the postprocessor.
int numActive(int _id)
Get the number of active post processors for viewer.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
void slotMoveUp()
move the selected active postprocessor 1 up
unsigned int activeId(int _id, int _chainIdx=0)
Get the id of the active post processor for viewer at chain index.
void slotDeactivatePostProcessor()
Deactivates the current postProcessor.
void slotContextMenuDeactivate(const QPoint &_point)
Show the custom context menu for deactivation.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void slotSaveActive()
saves active post processor chain
static QStringList getSavedPostProcessorNames(const unsigned _examiner)
return the names of all saved post processors
void slotActivatePostProcessor()
Activates the post processor (triggered via the context menu)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
QString description
Description of the plugin.
QString name
Name of the plugin ( requested from the plugin on load)
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void slotContextMenuActivate(const QPoint &_point)
Show the custom context menu for activation.
void refresh()
refreshes the content of the dialog with current examiner
void append(unsigned int _active, int _viewerId)
Append the active post processor to the chain for viewer.
QString version
Version of the plugin.
void remove(int _id, int _chainIdx)
Remove a post processor at the specified chain index.