KNewStuff
kdxsrating.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "kdxsrating.h"
00020
00021 #include "qstarframe.h"
00022
00023 #include <QtGui/QLayout>
00024 #include <QtGui/QSlider>
00025 #include <QtGui/QLabel>
00026
00027 #include <klocale.h>
00028 #include <kstandarddirs.h>
00029
00030 KDXSRating::KDXSRating(QWidget *parent)
00031 : KDialog(parent)
00032 {
00033 setCaption(i18n("Rate this entry"));
00034 setButtons(KDialog::Ok | KDialog::Cancel);
00035
00036 QVBoxLayout *vbox;
00037 QHBoxLayout *hbox;
00038
00039 QWidget *root = new QWidget(this);
00040 setMainWidget(root);
00041
00042 m_slider = new QSlider(root);
00043 m_slider->setOrientation(Qt::Horizontal);
00044 m_slider->setTickPosition(QSlider::TicksBelow);
00045 m_slider->setMinimum(0);
00046 m_slider->setMaximum(100);
00047
00048 m_starrating = new QStarFrame(root);
00049 m_starrating->setMinimumWidth(100);
00050
00051 m_rating = new QLabel(QString("0/100"), root);
00052 m_rating->setFixedWidth(100);
00053
00054 vbox = new QVBoxLayout(root);
00055 hbox = new QHBoxLayout();
00056 hbox->addWidget(m_rating);
00057 hbox->addWidget(m_starrating);
00058 vbox->addLayout(hbox);
00059 vbox->addWidget(m_slider);
00060
00061 connect(m_slider, SIGNAL(valueChanged(int)),
00062 m_starrating, SLOT(slotRating(int)));
00063 connect(m_slider, SIGNAL(valueChanged(int)), SLOT(slotRating(int)));
00064 }
00065
00066 int KDXSRating::rating()
00067 {
00068 return m_slider->value();
00069 }
00070
00071 void KDXSRating::slotRating(int rating)
00072 {
00073 m_rating->setText(QString("%1/100").arg(rating));
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 #include "kdxsrating.moc"