MediaList::~MediaList()
{
+ if (m_populated)
+ writeExpandedSettings();
}
/*
*/
void MediaList::populateTree()
{
- QTreeWidgetItem *mediatreeitem, *pooltreeitem, *topItem;
+ QTreeWidgetItem *mediatreeitem, *pooltreeitem;
if (!m_console->preventInUseConnect())
return;
int statusIndex = headerlist.indexOf("Status");
m_checkcurwidget = false;
+ if (m_populated)
+ writeExpandedSettings();
mp_treeWidget->clear();
m_checkcurwidget = true;
mp_treeWidget->setColumnCount(headerlist.count());
- topItem = new QTreeWidgetItem(mp_treeWidget);
- topItem->setText(0, "Pools");
- topItem->setData(0, Qt::UserRole, 0);
- topItem->setExpanded(true);
+ m_topItem = new QTreeWidgetItem(mp_treeWidget);
+ m_topItem->setText(0, "Pools");
+ m_topItem->setData(0, Qt::UserRole, 0);
+ m_topItem->setExpanded(true);
mp_treeWidget->setHeaderLabels(headerlist);
+ QSettings settings(m_console->m_dir->name(), "bat");
+ settings.beginGroup("MediaListTreeExpanded");
QString query;
foreach (QString pool_listItem, m_console->pool_list) {
- pooltreeitem = new QTreeWidgetItem(topItem);
+ pooltreeitem = new QTreeWidgetItem(m_topItem);
pooltreeitem->setText(0, pool_listItem);
pooltreeitem->setData(0, Qt::UserRole, 1);
- pooltreeitem->setExpanded(true);
+ if(settings.contains(pool_listItem)) {
+ pooltreeitem->setExpanded(settings.value(pool_listItem).toBool());
+ } else {
+ pooltreeitem->setExpanded(true);
+ }
query = "SELECT Media.VolumeName AS Media, "
" Media.MediaId AS Id, Media.VolStatus AS VolStatus,"
} /* foreach resultline */
} /* if results from query */
} /* foreach pool_listItem */
+ settings.endGroup();
/* Resize the columns */
for(int cnter=0; cnter<headerlist.count(); cnter++) {
mp_treeWidget->resizeColumnToContents(cnter);
consoleCommand(cmd);
populateTree();
}
+
+/*
+ * Write settings to save expanded states of the pools
+ */
+void MediaList::writeExpandedSettings()
+{
+ QSettings settings(m_console->m_dir->name(), "bat");
+ settings.beginGroup("MediaListTreeExpanded");
+ int childcount = m_topItem->childCount();
+ for (int cnt=0; cnt<childcount; cnt++) {
+ QTreeWidgetItem *poolitem = m_topItem->child(cnt);
+ settings.setValue(poolitem->text(0), poolitem->isExpanded());
+ }
+ settings.endGroup();
+}