/* * Alabastra Project - C++ Editor writed with QT Library V.4 * Copyright (C) Igor Maculan - geocronos@gmail.com Marco Buoncristiano - marco.buoncristiano@gmail.com * 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 * of the License, 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. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "AlListWidget.h" #include "AlTextEdit.h" #include "AlMethod.h" #include #include #include #include #include AlListWidget::AlListWidget(QWidget *parent) : QListWidget(parent){ setContextMenuPolicy(Qt::CustomContextMenu); connect(this,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(showMenu(const QPoint&))); }; /* * Restituisce il QListWidgetItem avendo come parametro di ingresso il documento che rappresenta */ QListWidgetItem* AlListWidget::getItem(AlDocument *doc){ QListWidgetItem *it=NULL; AlTextEdit *edt; int i=0; bool found=false; QVariant d; while (!found && idata(101); edt=(AlTextEdit*)d.value(); if ( edt->getAlDocument() == doc ){ found=true; it=item(i); } i++; } return it; }; /** *Restituisce il documento relativo al'item della lista passatogli come argomento */ AlTextEdit* AlListWidget::getEditor(QListWidgetItem *lit) { QVariant d=lit->data(101); AlTextEdit *edt; edt=(AlTextEdit*)d.value(); return edt; }; /* * Restituisce l'attuale documento */ AlTextEdit* AlListWidget::getEditor() { return getEditor(currentItem()); }; /* * Menu Contestuale */ void AlListWidget::showMenu(const QPoint &pos){ if (this->count()>0){ QMenu *menu=new QMenu(this); AlDocument *doc = getEditor()->getAlDocument(); if (doc->getExtension()=="h"){ QMenu *mnMentods = menu->addMenu(tr("Metodi")); QList methods = doc->getAlMethodList(); QMenu *mnMethodSingle; AlActionMethod *act; for (int i=0;igetReturnName()).arg(methods.at(i)->getName()); mnMethodSingle = mnMentods->addMenu(strMethod.simplified()); act=new AlActionMethod(this); act->setText(tr("Implementa")); act->setAlMethod(methods.at(i)); connect (act,SIGNAL(triggered()),this,SLOT(implementsMethod())); mnMethodSingle->addAction((QAction*)act); } } menu->popup(mapToGlobal(pos)); } }; void AlListWidget::implementsMethod(){ AlActionMethod *act = (AlActionMethod*) sender(); emit methodImplement(act->getAlMethod()->getImplementation()); };