mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
- Added Comboboxes in torrent properties. No usable yet but it will be very useful when we will support pieces prioritization
This commit is contained in:
parent
adf91c95d3
commit
d3eda2e8be
6
TODO
6
TODO
@ -29,6 +29,9 @@
|
||||
- Add a torrent scheduler
|
||||
- Improve Ipfilter.dat parser (move to a thread ? - too slow to load qBT and more importantly options)
|
||||
|
||||
// in v0.11
|
||||
- Tabs support in search
|
||||
|
||||
// in v0.10 (partial) - WIP
|
||||
- Download from RSS feeds (WIP by gtsoul, clean & finish rss.h, add a tab in mainWindow, debug)
|
||||
- Move finished torrent to another tab and keep on seeding them even after restart (debug)
|
||||
@ -39,5 +42,4 @@
|
||||
- Display more info in log (UPnP)
|
||||
- Update to libtorrent SVN (0.13)
|
||||
- Use its UPnP/NAT-PMP built-in support instead of ours
|
||||
- Use its piece prioritization support
|
||||
- Tab support in search (maybe a bit later)
|
||||
- Use its piece prioritization support (Add comboboxes in properties)
|
@ -22,8 +22,10 @@
|
||||
#ifndef PROPLISTDELEGATE_H
|
||||
#define PROPLISTDELEGATE_H
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QItemDelegate>
|
||||
#include <QStyleOptionProgressBarV2>
|
||||
#include <QStyleOptionComboBox>
|
||||
#include <QComboBox>
|
||||
#include <QModelIndex>
|
||||
#include <QPainter>
|
||||
#include <QProgressBar>
|
||||
@ -36,11 +38,11 @@
|
||||
#define PROGRESS 2
|
||||
#define SELECTED 3
|
||||
|
||||
class PropListDelegate: public QAbstractItemDelegate {
|
||||
class PropListDelegate: public QItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PropListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
|
||||
PropListDelegate(QObject *parent=0) : QItemDelegate(parent){}
|
||||
|
||||
~PropListDelegate(){}
|
||||
|
||||
@ -101,18 +103,55 @@ class PropListDelegate: public QAbstractItemDelegate {
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
}
|
||||
case SELECTED:
|
||||
case SELECTED:{
|
||||
QStyleOptionComboBox newopt;
|
||||
newopt.rect = opt.rect;
|
||||
if(index.data().toBool()){
|
||||
painter->drawText(option.rect, Qt::AlignCenter, tr("True"));
|
||||
// painter->drawText(option.rect, Qt::AlignCenter, tr("True"));
|
||||
newopt.currentText = tr("True");
|
||||
}else{
|
||||
painter->drawText(option.rect, Qt::AlignCenter, tr("False"));
|
||||
// painter->drawText(option.rect, Qt::AlignCenter, tr("False"));
|
||||
newopt.currentText = tr("False");
|
||||
}
|
||||
newopt.state |= QStyle::State_Enabled;
|
||||
// newopt.frame = true;
|
||||
// newopt.editable = true;
|
||||
QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &newopt,
|
||||
painter);
|
||||
opt.palette.setColor(QPalette::Text, QColor("black"));
|
||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||
painter->drawText(option.rect, Qt::AlignLeft, " "+newopt.currentText);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex & index) const {
|
||||
if(index.column() != SELECTED) return 0;
|
||||
QComboBox* editor = new QComboBox(parent);
|
||||
editor->setFocusPolicy(Qt::StrongFocus);
|
||||
editor->addItem(tr("True"));
|
||||
editor->addItem(tr("False"));
|
||||
return editor;
|
||||
}
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const {
|
||||
bool value = index.model()->data(index, Qt::DisplayRole).toBool();
|
||||
QComboBox *combobox = static_cast<QComboBox*>(editor);
|
||||
if(value) {
|
||||
combobox->setCurrentIndex(0);
|
||||
} else {
|
||||
combobox->setCurrentIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
// bool editorEvent(QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index ){
|
||||
// qDebug("Event!!!!");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||
QVariant value = index.data(Qt::FontRole);
|
||||
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
|
||||
@ -121,6 +160,29 @@ class PropListDelegate: public QAbstractItemDelegate {
|
||||
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
|
||||
return textRect.size();
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
||||
QComboBox *combobox = static_cast<QComboBox*>(editor);
|
||||
// combobox->interpretText();
|
||||
int value = combobox->currentIndex();
|
||||
qDebug("Setting combobox value in index: %d", value);
|
||||
QString color;
|
||||
if(value == 0) {
|
||||
model->setData(index, true);
|
||||
color = "green";
|
||||
} else {
|
||||
model->setData(index, false);
|
||||
color = "red";
|
||||
}
|
||||
for(int i=0; i<model->columnCount(); ++i){
|
||||
model->setData(model->index(index.row(), i), QVariant(QColor(color)), Qt::TextColorRole);
|
||||
}
|
||||
}
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const {
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="torrentContent" >
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab" >
|
||||
<attribute name="title" >
|
||||
@ -859,6 +859,9 @@
|
||||
<height>301</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editTriggers" >
|
||||
<set>QAbstractItemView::AllEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode" >
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
|
@ -44,7 +44,8 @@ properties::properties(QWidget *parent, torrent_handle &h, QStringList trackerEr
|
||||
filesList->setModel(PropListModel);
|
||||
PropDelegate = new PropListDelegate();
|
||||
filesList->setItemDelegate(PropDelegate);
|
||||
connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&)));
|
||||
// connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&)));
|
||||
connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&)));
|
||||
connect(addTracker_button, SIGNAL(clicked()), this, SLOT(askForTracker()));
|
||||
connect(removeTracker_button, SIGNAL(clicked()), this, SLOT(deleteSelectedTrackers()));
|
||||
connect(riseTracker_button, SIGNAL(clicked()), this, SLOT(riseSelectedTracker()));
|
||||
@ -304,27 +305,27 @@ void properties::setAllPiecesState(bool selected){
|
||||
|
||||
// Toggle the selected state of a file within the torrent when we
|
||||
// double click on it.
|
||||
void properties::toggleSelectedState(const QModelIndex& index){
|
||||
int row = index.row();
|
||||
if(selectionBitmask.at(row)){
|
||||
// File is selected
|
||||
selectionBitmask.erase(selectionBitmask.begin()+row);
|
||||
selectionBitmask.insert(selectionBitmask.begin()+row, 0);
|
||||
// Update list infos
|
||||
setRowColor(row, "green");
|
||||
PropListModel->setData(PropListModel->index(row, SELECTED), QVariant(true));
|
||||
}else{
|
||||
// File is not selected
|
||||
selectionBitmask.erase(selectionBitmask.begin()+row);
|
||||
selectionBitmask.insert(selectionBitmask.begin()+row, 1);
|
||||
// Update list infos
|
||||
setRowColor(row, "red");
|
||||
PropListModel->setData(PropListModel->index(row, SELECTED), QVariant(false));
|
||||
}
|
||||
h.filter_files(selectionBitmask);
|
||||
// Save filtered pieces to a file to remember them
|
||||
saveFilteredFiles();
|
||||
}
|
||||
// void properties::toggleSelectedState(const QModelIndex& index){
|
||||
// int row = index.row();
|
||||
// if(selectionBitmask.at(row)){
|
||||
// // File is selected
|
||||
// selectionBitmask.erase(selectionBitmask.begin()+row);
|
||||
// selectionBitmask.insert(selectionBitmask.begin()+row, 0);
|
||||
// // Update list infos
|
||||
// setRowColor(row, "green");
|
||||
// PropListModel->setData(PropListModel->index(row, SELECTED), QVariant(true));
|
||||
// }else{
|
||||
// // File is not selected
|
||||
// selectionBitmask.erase(selectionBitmask.begin()+row);
|
||||
// selectionBitmask.insert(selectionBitmask.begin()+row, 1);
|
||||
// // Update list infos
|
||||
// setRowColor(row, "red");
|
||||
// PropListModel->setData(PropListModel->index(row, SELECTED), QVariant(false));
|
||||
// }
|
||||
// h.filter_files(selectionBitmask);
|
||||
// // Save filtered pieces to a file to remember them
|
||||
// saveFilteredFiles();
|
||||
// }
|
||||
|
||||
void properties::on_incrementalDownload_stateChanged(int){
|
||||
qDebug("Incremental download toggled");
|
||||
|
@ -48,7 +48,7 @@ class properties : public QDialog, private Ui::properties{
|
||||
void on_okButton_clicked();
|
||||
void on_incrementalDownload_stateChanged(int);
|
||||
void setRowColor(int row, QString color);
|
||||
void toggleSelectedState(const QModelIndex& index);
|
||||
// void toggleSelectedState(const QModelIndex& index);
|
||||
void saveFilteredFiles();
|
||||
void updateProgress();
|
||||
void loadFilteredFiles();
|
||||
|
Loading…
Reference in New Issue
Block a user