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
00020
00021 #include "kdxsrating.h"
00022
00023 #include "qstarframe.h"
00024
00025 #include <QtGui/QLayout>
00026 #include <QtGui/QSlider>
00027 #include <QtGui/QLabel>
00028
00029 #include <klocale.h>
00030 #include <kstandarddirs.h>
00031
00032 KDXSRating::KDXSRating(QWidget *parent)
00033 : KDialog(parent)
00034 {
00035 setCaption(i18n("Rate this entry"));
00036 setButtons(KDialog::Ok | KDialog::Cancel);
00037
00038 QVBoxLayout *vbox;
00039 QHBoxLayout *hbox;
00040
00041 QWidget *root = new QWidget(this);
00042 setMainWidget(root);
00043
00044 m_slider = new QSlider(root);
00045 m_slider->setOrientation(Qt::Horizontal);
00046 m_slider->setTickPosition(QSlider::TicksBelow);
00047 m_slider->setMinimum(0);
00048 m_slider->setMaximum(100);
00049
00050 m_starrating = new QStarFrame(root);
00051 m_starrating->setMinimumWidth(100);
00052
00053 m_rating = new QLabel(QString("0/100"), root);
00054 m_rating->setFixedWidth(100);
00055
00056 vbox = new QVBoxLayout(root);
00057 hbox = new QHBoxLayout();
00058 hbox->addWidget(m_rating);
00059 hbox->addWidget(m_starrating);
00060 vbox->addLayout(hbox);
00061 vbox->addWidget(m_slider);
00062
00063 connect(m_slider, SIGNAL(valueChanged(int)),
00064 m_starrating, SLOT(slotRating(int)));
00065 connect(m_slider, SIGNAL(valueChanged(int)), SLOT(slotRating(int)));
00066 }
00067
00068 int KDXSRating::rating()
00069 {
00070 return m_slider->value();
00071 }
00072
00073 void KDXSRating::slotRating(int rating)
00074 {
00075 m_rating->setText(QString("%1/100").arg(rating));
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
00121
00122 #include "kdxsrating.moc"