PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/vp_plugins/tEditor/cmdframe.cpp

http://cupsfilter.googlecode.com/
C++ | 87 lines | 60 code | 13 blank | 14 comment | 2 complexity | cd2810e283259f00c45d1aa3e5b149fe MD5 | raw file
 1#include "cmdframe.h"
 2#include <QDebug>
 3#include <QPushButton>
 4#include <QVBoxLayout>
 5#include <QSignalMapper>
 6#include <QMessageBox>
 7
 8
 9cmdFrame::cmdFrame(QWidget *parent) :
10        QFrame(parent)
11{
12    signalMapper = new QSignalMapper(this);
13    qDebug() << "signalMapper:" << signalMapper;
14    verticalLayout = new QVBoxLayout();
15    verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
16    verticalLayout->setContentsMargins(0, 0, 0, 0);
17    addImgBtn = new QPushButton();
18    addImgBtn->setText(tr("???????????"));
19    addImgBtn->setObjectName(QString::fromUtf8("addImgBtn"));
20
21    connect(addImgBtn, SIGNAL(clicked()), signalMapper, SLOT(map()));
22    signalMapper->setMapping(addImgBtn, tr("???????????"));
23
24
25    verticalLayout->addWidget(addImgBtn);
26    /*
27
28
29    pushButton_2 = new QPushButton();
30    pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
31
32    verticalLayout->addWidget(pushButton_2);
33    */
34    this->setLayout(verticalLayout);
35    connect(signalMapper,
36            SIGNAL(mapped(const QString &)),
37            this,
38            SIGNAL(clicked(const QString &))
39            //SLOT(test())
40            );
41
42}
43
44void cmdFrame::test()
45{
46//    QMessageBox msgBox;
47//     msgBox.setText("The document has been modified.");
48//     msgBox.exec();
49//     emit test_signal();
50}
51
52void cmdFrame::setCmdButton(QStringList c_list)
53{
54    QPushButton *pBt;
55    for (int i=0;i<c_list.size();i++){
56        pBt = new QPushButton();
57        pBt->setText(c_list.at(i));
58        //qDebug() << "signalMapper:" << signalMapper << "pBt" <<pBt;
59        connect(pBt, SIGNAL(clicked()), signalMapper, SLOT(map()));
60        signalMapper->setMapping(pBt, QString("%1").arg(c_list.at(i)));
61        verticalLayout->addWidget(pBt);
62    }
63
64}
65
66cmdFrame::~cmdFrame()
67{
68
69}
70
71void cmdFrame::retranslateUi(QFrame *cmdFrame)
72{
73    cmdFrame->setWindowTitle(QApplication::translate("cmdFrame", "Frame", 0, QApplication::UnicodeUTF8));
74    Q_UNUSED(cmdFrame);
75} // retranslateUi
76
77void cmdFrame::changeEvent(QEvent *e)
78{
79    QFrame::changeEvent(e);
80    switch (e->type()) {
81    case QEvent::LanguageChange:
82        retranslateUi(this);
83        break;
84    default:
85        break;
86    }
87}