45 #include <OpenFlipper/common/RendererInfo.hh> 50 #include "postProcessorWidget.hh" 53 PostProcessorDialog::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"));
80 void PostProcessorDialog::closeEvent(QCloseEvent *_event)
86 void PostProcessorDialog::showEvent ( QShowEvent * )
96 activeRowToRow_.clear();
99 for (
int i = 0; i < postProcessorManager().
numActive(currentExaminer_); ++i)
101 unsigned int id = postProcessorManager().
activeId(currentExaminer_, i);
102 activeRowToRow_.push_back(
id);
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);
131 for (std::vector<unsigned>::iterator iter = activeRowToRow_.begin(); iter != activeRowToRow_.end() && !found; ++iter)
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 );
148 postProcessorManager().
append( currentRow, currentExaminer_);
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);
162 activeRowToRow_.push_back(currentRow);
165 emit updateExaminer(currentExaminer_);
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);
178 const unsigned activeID = activeRowToRow_[chainPos];
179 QListWidgetItem* item = list->item(activeID);
182 postProcessorManager().
remove(currentExaminer_, chainPos);
185 item->setHidden(
false);
186 item->setSelected(
true);
190 for (
unsigned i = chainPos; i < activeRowToRow_.size()-1; ++i)
191 activeRowToRow_[i] = activeRowToRow_[i+1];
194 activeItem = activeList->takeItem(activeList->row(activeItem));
197 activeRowToRow_.erase( activeRowToRow_.end()-selectedItems.size(), activeRowToRow_.end());
199 emit updateExaminer(currentExaminer_);
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;
224 const int activeID = activeRowToRow_[_from];
225 postProcessorManager().
remove(currentExaminer_, chainPos);
226 postProcessorManager().
insert(activeID,_to,currentExaminer_);
229 int inc = (_from > _to)? -1: +1;
230 for(
unsigned int currentRow = _from;currentRow != _to; currentRow += inc)
231 std::swap(activeRowToRow_[currentRow+inc],activeRowToRow_[currentRow]);
233 emit updateExaminer(currentExaminer_);
242 QMenu *menu =
new QMenu(list);
245 action = menu->addAction(tr(
"Activate"));
246 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(slotActivatePostProcessor()));
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"));
265 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(slotDeactivatePostProcessor()));
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);
314 template<
typename TCmp>
320 bool operator()(QListWidgetItem* left, QListWidgetItem* right)
322 return TCmp()(list_->row(left) , list_->row(right));
329 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
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);
344 slotMovePostProcessor(selectedRow,selectedRow+1);
352 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
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);
367 slotMovePostProcessor(selectedRow,selectedRow-1);
373 QStringList activeList(
"");
375 for (
int i = 0; i < postProcessorManager().
numActive(currentExaminer_); ++i)
377 unsigned int id = postProcessorManager().
activeId(currentExaminer_, i);
378 activeList.push_back(postProcessorManager()[
id]->name);
386 return OpenFlipperSettings().
value(QString(
"PostProcessor/Viewer/%1").arg(_examiner),QStringList(
"")).toStringList();
391 QStringList active = getSavedPostProcessorNames(_examiner);
392 for (QStringList::iterator iter = active.begin(); iter != active.end(); ++iter)
394 postProcessorManager().
append(*iter,_examiner);
static void loadSavedPostProcessors(const unsigned _examiner)
append all saved post processors
void slotDeactivatePostProcessor()
Deactivates the current postProcessor.
QString description
Description of the plugin.
QString version
Version of the plugin.
size_t available()
number of available post processor
void initWindow()
initiaize the window with the post processors of the current examiner
void slotMovePostProcessor(unsigned _from, unsigned _to)
Move the position/ordering of postprocessor in the postprocessor.
void slotMoveUp()
move the selected active postprocessor 1 up
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void remove(int _id, int _chainIdx)
Remove a post processor at the specified chain index.
QString name
Name of the plugin ( requested from the plugin on load)
void append(unsigned int _active, int _viewerId)
Append the active post processor to the chain for viewer.
void insert(unsigned int _active, int _chainIdx, int _viewerId)
Insert the active post processor to the chain for viewer.
void refresh()
refreshes the content of the dialog with current examiner
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
unsigned int activeId(int _id, int _chainIdx=0)
Get the id of the active post processor for viewer at chain index.
void slotContextMenuDeactivate(const QPoint &_point)
Show the custom context menu for deactivation.
int numActive(int _id)
Get the number of active post processors for viewer.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void slotMoveDown()
move the selected active postprocessor 1 down
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
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)
QAction * optionsAction
Possible action to add an options action or menu to the system.
void slotSaveActive()
saves active post processor chain
void slotContextMenuActivate(const QPoint &_point)
Show the custom context menu for activation.