Hello,

I am trying to implement a nice Citation dialog for qt4 but I have difficulties with the controller:

Right now, QCitation derives from QController<ControlCitation, QView<QCitationDialog> >. I have approximatively the same code as in the qt2 frontend but the OK and Apply buttons don't work properly. It seems that QCitation::update_content is properly called on construction but QCitation::apply is not called when Apply or OK button are pressed. There is an error message in the console:

NoRepeatedApplyReadOnlyPolicy: No transition for input SMI_APPLY from state INVALID

I've tried to understand the controller mechanism but it's really too convoluted for me (like A calls B calls C calls B calls A ...). So please if someone knows about this (Angus?), help me.

I am more and more agreeing with Andre about GUII. I am spending more time fitting into its concept than actually coding the GUI :-(
By the way, what's the "QCitation::hide" method for?

Abdel.

PS: QCitation.[Ch] attached.
/**
 * \file QCitation.C
 * This file is part of LyX, the document processor.
 * Licence details can be found in the file COPYING.
 *
 * \author Angus Leeming
 * \author Kalle Dalheimer
 *
 * Full author contact details are available in file CREDITS.
 */

#include <config.h>

#include "QCitation.h"
#include "QCitationDialog.h"
#include "Qt2BC.h"
#include "qt_helpers.h"

#include "bufferparams.h"

#include "controllers/ButtonController.h"
#include "controllers/ControlCitation.h"

#include "support/lstrings.h"

namespace lyx {
namespace frontend {

typedef QController<ControlCitation, QView<QCitationDialog> > base_class;

QCitation::QCitation(Dialog & parent)
        : base_class(parent, _("Citation"))
{
}


void QCitation::apply()
{
        dialog_->update(controller().params());
}


void QCitation::build_dialog()
{
        dialog_.reset(new QCitationDialog(this));
}


void QCitation::update_contents()
{
        // Make the list of all available bibliography keys
        bibkeys = biblio::getKeys(controller().bibkeysInfo());

        dialog_->update(controller().params());

        bc().valid(dialog_->isValid());
}

void QCitation::hide()
{
        bibkeys.clear();

        QDialogView::hide();
}

bool QCitation::isValid()
{
        return dialog_->isValid();
}


QString QCitation::getKeyInfo(int selection) const
{
        biblio::InfoMap const & theMap = controller().bibkeysInfo();
        if (!theMap.empty())
                        return toqstr(biblio::getInfo(theMap, 
bibkeys[selection]));

        return "";
}






} // namespace frontend
} // namespace lyx
// -*- C++ -*-
/**
 * \file QCitation.h
 * This file is part of LyX, the document processor.
 * Licence details can be found in the file COPYING.
 *
 * \author Angus Leeming
 * \author Kalle Dalheimer
 *
 * Full author contact details are available in file CREDITS.
 */

#ifndef QCITATION_H
#define QCITATION_H

#include "QDialogView.h"

#include <QString>
#include <vector>
#include <string>

namespace lyx {
namespace frontend {

class ControlCitation;
class QCitationDialog;


class QCitation : public QController<ControlCitation, QView<QCitationDialog> >
{
public:
        friend class QCitationDialog;
        ///
        QCitation(Dialog &);

        std::vector<std::string> const & availableKeys() const {
                return bibkeys;
        }
        
        QString QCitation::getKeyInfo(int selection) const;

protected:
        virtual bool isValid();

private:

        /// Set the Params variable for the Controller.
        virtual void apply();
        /// Build the dialog.
        virtual void build_dialog();
        /// Hide the dialog.
        virtual void hide();
        /// Update dialog before/whilst showing it.
        virtual void update_contents();

        /// available bib keys
        std::vector<std::string> bibkeys;

};

} // namespace frontend
} // namespace lyx

#endif // QCITATION_H

Reply via email to