Added "check/uncheck all items" feature to import/export dialog.

This commit is contained in:
Martin Rotter 2014-09-11 08:00:22 +02:00
parent 63ca878b5c
commit b264e95db4
5 changed files with 57 additions and 4 deletions

View File

@ -13,6 +13,7 @@ Fixed:
Added: Added:
<ul> <ul>
<li>Import/export dialog now offers "Check/uncheck all items" button.</li>
</ul> </ul>
Changed: Changed:

View File

@ -248,6 +248,18 @@ void FeedsImportExportModel::setMode(const FeedsImportExportModel::Mode &mode) {
m_mode = mode; m_mode = mode;
} }
void FeedsImportExportModel::checkAllItems() {
foreach (FeedsModelRootItem *root_child, m_rootItem->childItems()) {
setData(indexForItem(root_child), Qt::Checked, Qt::CheckStateRole);
}
}
void FeedsImportExportModel::uncheckAllItems() {
foreach (FeedsModelRootItem *root_child, m_rootItem->childItems()) {
setData(indexForItem(root_child), Qt::Unchecked, Qt::CheckStateRole);
}
}
QModelIndex FeedsImportExportModel::index(int row, int column, const QModelIndex &parent) const { QModelIndex FeedsImportExportModel::index(int row, int column, const QModelIndex &parent) const {
if (!hasIndex(row, column, parent)) { if (!hasIndex(row, column, parent)) {
return QModelIndex(); return QModelIndex();

View File

@ -65,6 +65,10 @@ class FeedsImportExportModel : public QAbstractItemModel {
Mode mode() const; Mode mode() const;
void setMode(const Mode &mode); void setMode(const Mode &mode);
public slots:
void checkAllItems();
void uncheckAllItems();
private: private:
QHash<FeedsModelRootItem*, Qt::CheckState> m_checkStates; QHash<FeedsModelRootItem*, Qt::CheckState> m_checkStates;
FeedsModelRootItem *m_rootItem; FeedsModelRootItem *m_rootItem;

View File

@ -40,6 +40,8 @@ FormImportExport::FormImportExport(QWidget *parent) : QDialog(parent), m_ui(new
connect(m_ui->m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(performAction())); connect(m_ui->m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(performAction()));
connect(m_ui->m_btnSelectFile, SIGNAL(clicked()), this, SLOT(selectFile())); connect(m_ui->m_btnSelectFile, SIGNAL(clicked()), this, SLOT(selectFile()));
connect(m_ui->m_btnCheckAllItems, SIGNAL(clicked()), m_model, SLOT(checkAllItems()));
connect(m_ui->m_btnUncheckAllItems, SIGNAL(clicked()), m_model, SLOT(uncheckAllItems()));
} }
FormImportExport::~FormImportExport() { FormImportExport::~FormImportExport() {
@ -64,7 +66,7 @@ void FormImportExport::setMode(const FeedsImportExportModel::Mode &mode) {
case FeedsImportExportModel::Import: { case FeedsImportExportModel::Import: {
m_ui->m_groupFile->setTitle(tr("Source file")); m_ui->m_groupFile->setTitle(tr("Source file"));
m_ui->m_groupFeeds->setTitle(tr("Target feeds && categories")); m_ui->m_groupFeeds->setTitle(tr("Target feeds && categories"));
m_ui->m_treeFeeds->setDisabled(true); m_ui->m_groupFeeds->setDisabled(true);
setWindowTitle(tr("Import feeds")); setWindowTitle(tr("Import feeds"));
setWindowIcon(qApp->icons()->fromTheme("document-import")); setWindowIcon(qApp->icons()->fromTheme("document-import"));
break; break;
@ -176,7 +178,7 @@ void FormImportExport::parseImportFile(const QString &file_name) {
if (parsing_result) { if (parsing_result) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Feeds were loaded."), tr("Feeds were loaded.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Feeds were loaded."), tr("Feeds were loaded."));
m_ui->m_treeFeeds->setEnabled(true); m_ui->m_groupFeeds->setEnabled(true);
m_ui->m_treeFeeds->setModel(m_model); m_ui->m_treeFeeds->setModel(m_model);
m_ui->m_treeFeeds->expandAll(); m_ui->m_treeFeeds->expandAll();
} }

View File

@ -42,8 +42,35 @@
<property name="title"> <property name="title">
<string/> <string/>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QGridLayout" name="gridLayout">
<item> <item row="0" column="1">
<widget class="QPushButton" name="m_btnCheckAllItems">
<property name="text">
<string>&amp;Check all items</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="m_btnUncheckAllItems">
<property name="text">
<string>&amp;Uncheck all items</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="3">
<widget class="QTreeView" name="m_treeFeeds"> <widget class="QTreeView" name="m_treeFeeds">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -110,6 +137,13 @@
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>m_btnSelectFile</tabstop>
<tabstop>m_btnCheckAllItems</tabstop>
<tabstop>m_btnUncheckAllItems</tabstop>
<tabstop>m_treeFeeds</tabstop>
<tabstop>m_buttonBox</tabstop>
</tabstops>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>