45#include <OpenFlipper/common/RendererInfo.hh>
50#include "postProcessorWidget.hh"
53PostProcessorDialog::PostProcessorDialog(QWidget *_parent)
58 list->setContextMenuPolicy(Qt::CustomContextMenu);
59 activeList->setContextMenuPolicy(Qt::CustomContextMenu);
61 connect(closeButton, SIGNAL(clicked()),
this, SLOT(accept()));
62 connect(list,SIGNAL(customContextMenuRequested(
const QPoint&)),
this,SLOT(slotContextMenuActivate(
const QPoint&)));
63 connect(activeList,SIGNAL(customContextMenuRequested(
const QPoint&)),
this,SLOT(slotContextMenuDeactivate(
const QPoint&)));
64 connect(activateButton,SIGNAL(clicked()),
this,SLOT(slotActivatePostProcessor()));
65 connect(deactivateButton,SIGNAL(clicked()),
this,SLOT(slotDeactivatePostProcessor()));
66 connect(upButton,SIGNAL(clicked()),
this,SLOT(slotMoveUp()));
67 connect(downButton,SIGNAL(clicked()),
this,SLOT(slotMoveDown()));
68 connect(saveButton,SIGNAL(clicked()),
this,SLOT(slotSaveActive()));
69 connect(refreshButton,SIGNAL(clicked()),
this,SLOT(refresh()));
72 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
74 closeButton->setIcon( QIcon(iconPath +
"window-close.png"));
75 saveButton->setIcon( QIcon(iconPath +
"document-save.png"));
76 refreshButton->setIcon( QIcon(iconPath +
"edit-redo.png"));
80void PostProcessorDialog::closeEvent(QCloseEvent *_event)
86void PostProcessorDialog::showEvent ( QShowEvent * )
104 QListWidgetItem *activeItem =
new QListWidgetItem(
"");
105 activeList->addItem(activeItem);
106 QFrame* frame = createFrame(*postProcessorManager()[
id]);
107 activeItem->setSizeHint(frame->sizeHint());
108 activeList->setItemWidget(activeItem,frame);
112 for (
unsigned int i = 0 ; i < postProcessorManager().
available() ; ++i)
120 QFrame* frame = createFrame(*processor);
122 QListWidgetItem *item =
new QListWidgetItem(
"");
123 item->setSizeHint( frame->sizeHint() );
127 list->setItemWidget(item, frame);
132 found = (*iter == i);
134 list->setRowHidden(list->row(item),
true);
141 QList<QListWidgetItem*> selectedItems = list->selectedItems();
143 for (
int i=0; i < selectedItems.size(); ++i)
145 QListWidgetItem* item = selectedItems[i];
146 const int currentRow = list->row( item );
151 item->setHidden(
true);
152 item->setSelected(
false);
155 QListWidgetItem *activeItem =
new QListWidgetItem(
"");
156 activeList->addItem(activeItem);
157 activeItem->setSelected(
true);
159 QFrame* frame = createFrame(*postProcessorManager()[currentRow]);
160 activeItem->setSizeHint( frame->sizeHint() );
161 activeList->setItemWidget(activeItem,frame);
171 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
173 for (
int i=0; i < selectedItems.size(); ++i)
175 QListWidgetItem* activeItem = selectedItems[i];
177 const unsigned chainPos = activeList->row(activeItem);
179 QListWidgetItem* item = list->item(activeID);
185 item->setHidden(
false);
186 item->setSelected(
true);
194 activeItem = activeList->takeItem(activeList->row(activeItem));
205 if (_from >=
static_cast<unsigned>(activeList->count()))
208 if (_to >=
static_cast<unsigned>(activeList->count()))
209 _to = activeList->count()-1;
215 QListWidgetItem* activeItem = activeList->takeItem(_from);
216 activeList->insertItem(_to,activeItem);
217 QFrame* frame = createFrame(*postProcessorManager()[
activeRowToRow_[_from]]);
218 activeItem->setSizeHint(frame->sizeHint());
219 activeList->setItemWidget(activeItem,frame);
220 activeItem->setSelected(
true);
223 const int chainPos = _from;
229 int inc = (_from > _to)? -1: +1;
230 for(
unsigned int currentRow = _from;currentRow != _to; currentRow += inc)
242 QMenu *menu =
new QMenu(list);
245 action = menu->addAction(tr(
"Activate"));
248 menu->exec(list->mapToGlobal(_point),0);
254 if (!activeList->count())
257 QMenu *menu =
new QMenu(activeList);
260 action = menu->addAction(tr(
"Up"));
261 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(
slotMoveUp()));
262 action = menu->addAction(tr(
"Down"));
263 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(
slotMoveDown()));
264 action = menu->addAction(tr(
"Deactivate"));
267 menu->exec(activeList->mapToGlobal(_point),0);
273 QFrame* frame =
new QFrame();
274 QHBoxLayout* hlayout =
new QHBoxLayout;
276 QLabel* name =
new QLabel( _pPI.
name );
279 font.setPointSize(10);
281 QLabel* version =
new QLabel( _pPI.
version );
282 QPushButton* optionsButton =
new QPushButton(
"Options");
283 hlayout->addWidget(name);
284 hlayout->addStretch();
285 hlayout->addWidget(version);
287 optionsButton->setEnabled(
false);
290 optionsButton->setEnabled(
true);
291 connect(optionsButton,SIGNAL(clicked()),_pPI.
optionsAction,SLOT(trigger()));
294 QVBoxLayout* vlayout =
new QVBoxLayout;
296 QLabel* description =
new QLabel( _pPI.
description );
298 vlayout->addLayout(hlayout,20);
300 QHBoxLayout* optionsLayout =
new QHBoxLayout();
301 vlayout->addLayout(optionsLayout);
302 optionsLayout->addWidget(description);
303 optionsLayout->addStretch();
304 optionsLayout->addWidget(optionsButton);
306 frame->setLayout(vlayout);
314template<
typename TCmp>
320 bool operator()(QListWidgetItem* left, QListWidgetItem* right)
322 return TCmp()(list_->row(left) , list_->row(right));
329 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
332 std::sort(selectedItems.begin(), selectedItems.end(),
QListWidgetRowCmp<std::greater<int> >(activeList));
336 for(
int i=0; i < selectedItems.size() && activeList->row(selectedItems[i]) == activeList->count()-1-i;++i)
340 for (
int i=selectedItems.size()-1+start; i >= 0 ; --i)
342 QListWidgetItem* activeItem = activeList->selectedItems()[i];
343 unsigned selectedRow = activeList->row(activeItem);
352 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
355 std::sort(selectedItems.begin(), selectedItems.end(),
QListWidgetRowCmp<std::less<int> >(activeList));
359 for(
int i=0; i < selectedItems.size() && activeList->row(selectedItems[i]) == i;++i)
363 for (
int i=start; i < selectedItems.size(); ++i)
365 QListWidgetItem* activeItem = selectedItems[i];
366 unsigned selectedRow = activeList->row(activeItem);
373 QStringList activeList(
"");
378 activeList.push_back(postProcessorManager()[
id]->name);
386 return OpenFlipperSettings().
value(QString(
"PostProcessor/Viewer/%1").arg(_examiner),QStringList(
"")).toStringList();
392 for (QStringList::iterator iter = active.begin(); iter != active.end(); ++iter)
394 postProcessorManager().
append(*iter,_examiner);
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void initWindow()
initiaize the window with the post processors of the current examiner
static void loadSavedPostProcessors(const unsigned _examiner)
append all saved post processors
std::vector< unsigned > activeRowToRow_
maps activeRow from activeList (same as chainIdx from RendererInfo) to row from list (same as activeI...
static QStringList getSavedPostProcessorNames(const unsigned _examiner)
return the names of all saved post processors
void slotMoveUp()
move the selected active postprocessor 1 up
void slotDeactivatePostProcessor()
Deactivates the current postProcessor.
void slotContextMenuActivate(const QPoint &_point)
Show the custom context menu for activation.
void slotMovePostProcessor(unsigned _from, unsigned _to)
Move the position/ordering of postprocessor in the postprocessor.
void updateExaminer(unsigned _viewer)
request an update for an specified viewer
unsigned currentExaminer_
holds the examiner id for the window
void slotSaveActive()
saves active post processor chain
void refresh()
refreshes the content of the dialog with current examiner
void slotActivatePostProcessor()
Activates the post processor (triggered via the context menu)
void slotMoveDown()
move the selected active postprocessor 1 down
void slotContextMenuDeactivate(const QPoint &_point)
Show the custom context menu for deactivation.
QAction * optionsAction
Possible action to add an options action or menu to the system.
QString name
Name of the plugin ( requested from the plugin on load)
QString version
Version of the plugin.
QString description
Description of the plugin.
unsigned int activeId(int _id, int _chainIdx=0)
Get the id of the active post processor for viewer at chain index.
size_t available()
number of available post processor
int numActive(int _id)
Get the number of active post processors for viewer.
void append(unsigned int _active, int _viewerId)
Append the active post processor to the chain for viewer.
void remove(int _id, int _chainIdx)
Remove a post processor at the specified chain index.
void insert(unsigned int _active, int _chainIdx, int _viewerId)
Insert the active post processor to the chain for viewer.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.