mirror of https://github.com/KLayout/klayout.git
Salt manager dialog: UI enhancements
* refresh function for salt mine * Split "new" tab into "updates" and "new installations" * A warning icon in the tab when updates are available
This commit is contained in:
parent
6ba251cf2a
commit
7e1e75ebf0
|
|
@ -408,9 +408,299 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_3">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Update Packages</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter_update">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget_3">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_7">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="mark_update_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Mark or unmark for installation</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Mark</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="layResources.qrc">
|
||||||
|
<normaloff>:/marked_16.png</normaloff>:/marked_16.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>126</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="layResources.qrc">:/find.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="lay::DecoratedLineEdit" name="search_update_edit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_8">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="salt_mine_view_update">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="selectionRectVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" name="details_update_frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_9">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Details</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="toolButton_2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="layResources.qrc">
|
||||||
|
<normaloff>:/empty_16.png</normaloff>:/empty_16.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="lay::SaltGrainDetailsTextWidget" name="details_update_text">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_10">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="apply_update_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Apply</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="apply_label_update">
|
||||||
|
<property name="text">
|
||||||
|
<string>Set in code</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>563</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Install or Update Packages</string>
|
<string>Install New Packages</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -454,7 +744,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="mark_button">
|
<widget class="QToolButton" name="mark_new_button">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Mark or unmark for installation</string>
|
<string>Mark or unmark for installation</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -528,7 +818,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="salt_mine_view">
|
<widget class="QListView" name="salt_mine_view_new">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -661,7 +951,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="apply_button">
|
<widget class="QPushButton" name="apply_new_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Apply</string>
|
<string>Apply</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -674,7 +964,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="apply_label">
|
<widget class="QLabel" name="apply_label_new">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Set in code</string>
|
<string>Set in code</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -732,21 +1022,44 @@
|
||||||
<string>Delete package</string>
|
<string>Delete package</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionUnmarkAll">
|
<action name="actionUnmarkAllNew">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Unmark all</string>
|
<string>Unmark all</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionShowMarkedOnly">
|
<action name="actionShowMarkedOnlyNew">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show marked only</string>
|
<string>Show marked only</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionShowAll">
|
<action name="actionShowAllNew">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show all</string>
|
<string>Show all</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionRefresh">
|
||||||
|
<property name="text">
|
||||||
|
<string>Refresh</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Reload package repository</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionShowAllUpdate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show all</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionShowMarkedOnlyUpdate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show marked only</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionUnmarkAllUpdate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unmark all</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
@ -767,11 +1080,11 @@
|
||||||
<tabstop>details_text</tabstop>
|
<tabstop>details_text</tabstop>
|
||||||
<tabstop>edit_button</tabstop>
|
<tabstop>edit_button</tabstop>
|
||||||
<tabstop>search_new_edit</tabstop>
|
<tabstop>search_new_edit</tabstop>
|
||||||
<tabstop>mark_button</tabstop>
|
<tabstop>mark_new_button</tabstop>
|
||||||
<tabstop>salt_mine_view</tabstop>
|
<tabstop>salt_mine_view_new</tabstop>
|
||||||
<tabstop>details_new_text</tabstop>
|
<tabstop>details_new_text</tabstop>
|
||||||
<tabstop>toolButton</tabstop>
|
<tabstop>toolButton</tabstop>
|
||||||
<tabstop>apply_button</tabstop>
|
<tabstop>apply_new_button</tabstop>
|
||||||
<tabstop>scrollArea</tabstop>
|
<tabstop>scrollArea</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
||||||
|
|
@ -121,16 +121,7 @@ SaltController::show_editor ()
|
||||||
{
|
{
|
||||||
if (mp_mw && !mp_salt_dialog) {
|
if (mp_mw && !mp_salt_dialog) {
|
||||||
|
|
||||||
try {
|
mp_salt_dialog = new lay::SaltManagerDialog (mp_mw, &m_salt, m_salt_mine_url);
|
||||||
if (! m_salt_mine_url.empty ()) {
|
|
||||||
tl::log << tl::to_string (tr ("Downloading package repository from %1").arg (tl::to_qstring (m_salt_mine_url)));
|
|
||||||
m_salt_mine.load (m_salt_mine_url);
|
|
||||||
}
|
|
||||||
} catch (tl::Exception &ex) {
|
|
||||||
tl::error << ex.msg ();
|
|
||||||
}
|
|
||||||
|
|
||||||
mp_salt_dialog = new lay::SaltManagerDialog (mp_mw, &m_salt, &m_salt_mine);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,10 @@ private:
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// SaltManager implementation
|
// SaltManager implementation
|
||||||
|
|
||||||
SaltManagerDialog::SaltManagerDialog (QWidget *parent, lay::Salt *salt, lay::Salt *salt_mine)
|
SaltManagerDialog::SaltManagerDialog (QWidget *parent, lay::Salt *salt, const std::string &salt_mine_url)
|
||||||
: QDialog (parent),
|
: QDialog (parent),
|
||||||
m_current_changed_enabled (true), dm_update_models (this, &SaltManagerDialog::update_models)
|
m_salt_mine_url (salt_mine_url),
|
||||||
|
dm_update_models (this, &SaltManagerDialog::update_models), m_current_tab (-1)
|
||||||
{
|
{
|
||||||
Ui::SaltManagerDialog::setupUi (this);
|
Ui::SaltManagerDialog::setupUi (this);
|
||||||
mp_properties_dialog = new lay::SaltGrainPropertiesDialog (this);
|
mp_properties_dialog = new lay::SaltGrainPropertiesDialog (this);
|
||||||
|
|
@ -119,106 +120,213 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent, lay::Salt *salt, lay::Sal
|
||||||
connect (edit_button, SIGNAL (clicked ()), this, SLOT (edit_properties ()));
|
connect (edit_button, SIGNAL (clicked ()), this, SLOT (edit_properties ()));
|
||||||
connect (create_button, SIGNAL (clicked ()), this, SLOT (create_grain ()));
|
connect (create_button, SIGNAL (clicked ()), this, SLOT (create_grain ()));
|
||||||
connect (delete_button, SIGNAL (clicked ()), this, SLOT (delete_grain ()));
|
connect (delete_button, SIGNAL (clicked ()), this, SLOT (delete_grain ()));
|
||||||
connect (apply_button, SIGNAL (clicked ()), this, SLOT (apply ()));
|
connect (apply_new_button, SIGNAL (clicked ()), this, SLOT (apply ()));
|
||||||
|
connect (apply_update_button, SIGNAL (clicked ()), this, SLOT (apply ()));
|
||||||
|
|
||||||
mp_salt = salt;
|
mp_salt = salt;
|
||||||
mp_salt_mine = salt_mine;
|
|
||||||
|
try {
|
||||||
|
if (! m_salt_mine_url.empty ()) {
|
||||||
|
tl::log << tl::to_string (tr ("Downloading package repository from %1").arg (tl::to_qstring (m_salt_mine_url)));
|
||||||
|
m_salt_mine.load (m_salt_mine_url);
|
||||||
|
}
|
||||||
|
} catch (tl::Exception &ex) {
|
||||||
|
tl::error << ex.msg ();
|
||||||
|
}
|
||||||
|
|
||||||
SaltModel *model = new SaltModel (this, mp_salt);
|
SaltModel *model = new SaltModel (this, mp_salt);
|
||||||
salt_view->setModel (model);
|
salt_view->setModel (model);
|
||||||
salt_view->setItemDelegate (new SaltItemDelegate (this));
|
salt_view->setItemDelegate (new SaltItemDelegate (this));
|
||||||
|
|
||||||
SaltModel *mine_model = new SaltModel (this, mp_salt_mine);
|
SaltModel *mine_model;
|
||||||
salt_mine_view->setModel (mine_model);
|
|
||||||
salt_mine_view->setItemDelegate (new SaltItemDelegate (this));
|
// This model will show only the grains of mp_salt_mine which are not present in mp_salt yet.
|
||||||
|
mine_model = new SaltModel (this, &m_salt_mine, mp_salt, true);
|
||||||
|
salt_mine_view_new->setModel (mine_model);
|
||||||
|
salt_mine_view_new->setItemDelegate (new SaltItemDelegate (this));
|
||||||
|
|
||||||
|
// This model will show only the grains of mp_salt_mine which are present in mp_salt already.
|
||||||
|
mine_model = new SaltModel (this, &m_salt_mine, mp_salt, false);
|
||||||
|
salt_mine_view_update->setModel (mine_model);
|
||||||
|
salt_mine_view_update->setItemDelegate (new SaltItemDelegate (this));
|
||||||
|
|
||||||
mode_tab->setCurrentIndex (mp_salt->is_empty () ? 1 : 0);
|
mode_tab->setCurrentIndex (mp_salt->is_empty () ? 1 : 0);
|
||||||
|
|
||||||
connect (mode_tab, SIGNAL (currentChanged (int)), this, SLOT (mode_changed ()));
|
connect (mode_tab, SIGNAL (currentChanged (int)), this, SLOT (mode_changed ()));
|
||||||
|
m_current_tab = mode_tab->currentIndex ();
|
||||||
|
|
||||||
connect (mp_salt, SIGNAL (collections_changed ()), this, SLOT (salt_changed ()));
|
connect (mp_salt, SIGNAL (collections_changed ()), this, SLOT (salt_changed ()));
|
||||||
connect (mp_salt, SIGNAL (collections_about_to_change ()), this, SLOT (salt_about_to_change ()));
|
connect (mp_salt, SIGNAL (collections_about_to_change ()), this, SLOT (salt_about_to_change ()));
|
||||||
connect (mp_salt_mine, SIGNAL (collections_changed ()), this, SLOT (salt_mine_changed ()));
|
connect (&m_salt_mine, SIGNAL (collections_changed ()), this, SLOT (salt_mine_changed ()));
|
||||||
connect (mp_salt_mine, SIGNAL (collections_about_to_change ()), this, SLOT (salt_mine_about_to_change ()));
|
connect (&m_salt_mine, SIGNAL (collections_about_to_change ()), this, SLOT (salt_mine_about_to_change ()));
|
||||||
|
|
||||||
update_models ();
|
update_models ();
|
||||||
|
|
||||||
connect (salt_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_changed ()));
|
connect (salt_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_changed ()));
|
||||||
connect (salt_view, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (edit_properties ()));
|
connect (salt_view, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (edit_properties ()));
|
||||||
connect (salt_mine_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (mine_current_changed ()), Qt::QueuedConnection);
|
connect (salt_mine_view_new->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (mine_new_current_changed ()), Qt::QueuedConnection);
|
||||||
connect (salt_mine_view, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (mark_clicked ()));
|
connect (salt_mine_view_update->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (mine_update_current_changed ()), Qt::QueuedConnection);
|
||||||
|
connect (salt_mine_view_new, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (mark_clicked ()));
|
||||||
|
connect (salt_mine_view_update, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (mark_clicked ()));
|
||||||
|
|
||||||
search_installed_edit->set_clear_button_enabled (true);
|
search_installed_edit->set_clear_button_enabled (true);
|
||||||
search_new_edit->set_clear_button_enabled (true);
|
search_new_edit->set_clear_button_enabled (true);
|
||||||
|
search_update_edit->set_clear_button_enabled (true);
|
||||||
connect (search_installed_edit, SIGNAL (textChanged (const QString &)), this, SLOT (search_text_changed (const QString &)));
|
connect (search_installed_edit, SIGNAL (textChanged (const QString &)), this, SLOT (search_text_changed (const QString &)));
|
||||||
connect (search_new_edit, SIGNAL (textChanged (const QString &)), this, SLOT (search_text_changed (const QString &)));
|
connect (search_new_edit, SIGNAL (textChanged (const QString &)), this, SLOT (search_text_changed (const QString &)));
|
||||||
|
connect (search_update_edit, SIGNAL (textChanged (const QString &)), this, SLOT (search_text_changed (const QString &)));
|
||||||
|
|
||||||
connect (mark_button, SIGNAL (clicked ()), this, SLOT (mark_clicked ()));
|
connect (mark_new_button, SIGNAL (clicked ()), this, SLOT (mark_clicked ()));
|
||||||
|
connect (mark_update_button, SIGNAL (clicked ()), this, SLOT (mark_clicked ()));
|
||||||
|
|
||||||
salt_mine_view->addAction (actionUnmarkAll);
|
QAction *a;
|
||||||
QAction *a = new QAction (this);
|
|
||||||
|
salt_mine_view_new->addAction (actionUnmarkAllNew);
|
||||||
|
a = new QAction (this);
|
||||||
a->setSeparator (true);
|
a->setSeparator (true);
|
||||||
salt_mine_view->addAction (a);
|
salt_mine_view_new->addAction (a);
|
||||||
salt_mine_view->addAction (actionShowMarkedOnly);
|
salt_mine_view_new->addAction (actionShowMarkedOnlyNew);
|
||||||
salt_mine_view->addAction (actionShowAll);
|
salt_mine_view_new->addAction (actionShowAllNew);
|
||||||
salt_mine_view->setContextMenuPolicy (Qt::ActionsContextMenu);
|
a = new QAction (this);
|
||||||
|
a->setSeparator (true);
|
||||||
|
salt_mine_view_new->addAction (a);
|
||||||
|
salt_mine_view_new->addAction (actionRefresh);
|
||||||
|
salt_mine_view_new->setContextMenuPolicy (Qt::ActionsContextMenu);
|
||||||
|
|
||||||
connect (actionUnmarkAll, SIGNAL (triggered ()), this, SLOT (unmark_all ()));
|
salt_mine_view_update->addAction (actionUnmarkAllUpdate);
|
||||||
connect (actionShowMarkedOnly, SIGNAL (triggered ()), this, SLOT (show_marked_only ()));
|
a = new QAction (this);
|
||||||
connect (actionShowAll, SIGNAL (triggered ()), this, SLOT (show_all ()));
|
a->setSeparator (true);
|
||||||
|
salt_mine_view_update->addAction (a);
|
||||||
|
salt_mine_view_update->addAction (actionShowMarkedOnlyUpdate);
|
||||||
|
salt_mine_view_update->addAction (actionShowAllUpdate);
|
||||||
|
a = new QAction (this);
|
||||||
|
a->setSeparator (true);
|
||||||
|
salt_mine_view_update->addAction (a);
|
||||||
|
salt_mine_view_update->addAction (actionRefresh);
|
||||||
|
salt_mine_view_update->setContextMenuPolicy (Qt::ActionsContextMenu);
|
||||||
|
|
||||||
|
connect (actionUnmarkAllNew, SIGNAL (triggered ()), this, SLOT (unmark_all_new ()));
|
||||||
|
connect (actionShowMarkedOnlyNew, SIGNAL (triggered ()), this, SLOT (show_marked_only_new ()));
|
||||||
|
connect (actionShowAllNew, SIGNAL (triggered ()), this, SLOT (show_all_new ()));
|
||||||
|
connect (actionUnmarkAllUpdate, SIGNAL (triggered ()), this, SLOT (unmark_all_update ()));
|
||||||
|
connect (actionShowMarkedOnlyUpdate, SIGNAL (triggered ()), this, SLOT (show_marked_only_update ()));
|
||||||
|
connect (actionShowAllUpdate, SIGNAL (triggered ()), this, SLOT (show_all_update ()));
|
||||||
|
connect (actionRefresh, SIGNAL (triggered ()), this, SLOT (refresh ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::mode_changed ()
|
SaltManagerDialog::mode_changed ()
|
||||||
{
|
{
|
||||||
|
QList<int> sizes;
|
||||||
|
if (m_current_tab == 0) {
|
||||||
|
sizes = splitter->sizes ();
|
||||||
|
} else if (m_current_tab == 1) {
|
||||||
|
sizes = splitter_update->sizes ();
|
||||||
|
} else if (m_current_tab == 2) {
|
||||||
|
sizes = splitter_new->sizes ();
|
||||||
|
}
|
||||||
|
|
||||||
// keeps the splitters in sync
|
// keeps the splitters in sync
|
||||||
if (mode_tab->currentIndex () == 1) {
|
if (!sizes.empty ()) {
|
||||||
splitter_new->setSizes (splitter->sizes ());
|
splitter_new->setSizes (sizes);
|
||||||
show_all ();
|
splitter_update->setSizes (sizes);
|
||||||
} else if (mode_tab->currentIndex () == 0) {
|
splitter->setSizes (sizes);
|
||||||
splitter->setSizes (splitter_new->sizes ());
|
}
|
||||||
|
|
||||||
|
if (mode_tab->currentIndex () >= 1) {
|
||||||
|
show_all_new ();
|
||||||
|
show_all_update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_current_tab = mode_tab->currentIndex ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaltManagerDialog::show_all_new ()
|
||||||
|
{
|
||||||
|
search_new_edit->clear ();
|
||||||
|
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
|
if (model) {
|
||||||
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
|
--i;
|
||||||
|
salt_mine_view_new->setRowHidden (i, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::show_all ()
|
SaltManagerDialog::show_all_update ()
|
||||||
{
|
{
|
||||||
search_new_edit->clear ();
|
search_update_edit->clear ();
|
||||||
|
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
if (! model) {
|
if (model) {
|
||||||
return;
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
}
|
--i;
|
||||||
|
salt_mine_view_update->setRowHidden (i, false);
|
||||||
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
}
|
||||||
--i;
|
|
||||||
salt_mine_view->setRowHidden (i, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::show_marked_only ()
|
SaltManagerDialog::show_marked_only_new ()
|
||||||
{
|
{
|
||||||
search_new_edit->clear ();
|
search_new_edit->clear ();
|
||||||
|
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
if (! model) {
|
if (! model) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
salt_mine_view_new->setCurrentIndex (QModelIndex ());
|
||||||
|
|
||||||
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
--i;
|
--i;
|
||||||
SaltGrain *g = model->grain_from_index (model->index (i, 0, QModelIndex ()));
|
SaltGrain *g = model->grain_from_index (model->index (i, 0, QModelIndex ()));
|
||||||
salt_mine_view->setRowHidden (i, !(g && model->is_marked (g->name ())));
|
salt_mine_view_new->setRowHidden (i, !(g && model->is_marked (g->name ())));
|
||||||
|
mine_new_current_changed ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::unmark_all ()
|
SaltManagerDialog::show_marked_only_update ()
|
||||||
{
|
{
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
search_update_edit->clear ();
|
||||||
|
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
|
if (! model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
salt_mine_view_update->setCurrentIndex (QModelIndex ());
|
||||||
|
|
||||||
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
|
--i;
|
||||||
|
SaltGrain *g = model->grain_from_index (model->index (i, 0, QModelIndex ()));
|
||||||
|
salt_mine_view_update->setRowHidden (i, !(g && model->is_marked (g->name ())));
|
||||||
|
mine_update_current_changed ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaltManagerDialog::unmark_all_new ()
|
||||||
|
{
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
if (model) {
|
if (model) {
|
||||||
model->clear_marked ();
|
model->clear_marked ();
|
||||||
|
show_all_new ();
|
||||||
|
update_apply_state ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaltManagerDialog::unmark_all_update ()
|
||||||
|
{
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
|
if (model) {
|
||||||
|
model->clear_marked ();
|
||||||
|
show_all_update ();
|
||||||
update_apply_state ();
|
update_apply_state ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +338,9 @@ SaltManagerDialog::search_text_changed (const QString &text)
|
||||||
if (sender () == search_installed_edit) {
|
if (sender () == search_installed_edit) {
|
||||||
view = salt_view;
|
view = salt_view;
|
||||||
} else if (sender () == search_new_edit) {
|
} else if (sender () == search_new_edit) {
|
||||||
view = salt_mine_view;
|
view = salt_mine_view_new;
|
||||||
|
} else if (sender () == search_update_edit) {
|
||||||
|
view = salt_mine_view_update;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -265,45 +375,78 @@ SaltManagerDialog::search_text_changed (const QString &text)
|
||||||
void
|
void
|
||||||
SaltManagerDialog::mark_clicked ()
|
SaltManagerDialog::mark_clicked ()
|
||||||
{
|
{
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
QListView *view;
|
||||||
|
if (sender () == salt_mine_view_new || sender () == mark_new_button) {
|
||||||
|
view = salt_mine_view_new;
|
||||||
|
} else {
|
||||||
|
view = salt_mine_view_update;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (view->model ());
|
||||||
if (! model) {
|
if (! model) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SaltGrain *g = mine_current_grain ();
|
|
||||||
if (! g) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
model->set_marked (g->name (), !model->is_marked (g->name ()));
|
SaltGrain *g = model->grain_from_index (view->currentIndex ());
|
||||||
update_apply_state ();
|
if (g) {
|
||||||
|
model->set_marked (g->name (), ! model->is_marked (g->name ()));
|
||||||
|
update_apply_state ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::update_apply_state ()
|
SaltManagerDialog::update_apply_state ()
|
||||||
{
|
{
|
||||||
int marked = 0;
|
SaltModel *model;
|
||||||
|
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
if (! model) {
|
if (model) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
int marked = 0;
|
||||||
--i;
|
|
||||||
QModelIndex index = model->index (i, 0, QModelIndex ());
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
SaltGrain *g = model->grain_from_index (index);
|
--i;
|
||||||
if (g && model->is_marked (g->name ())) {
|
QModelIndex index = model->index (i, 0, QModelIndex ());
|
||||||
marked += 1;
|
SaltGrain *g = model->grain_from_index (index);
|
||||||
|
if (g && model->is_marked (g->name ())) {
|
||||||
|
marked += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply_new_button->setEnabled (marked > 0);
|
||||||
|
if (marked == 0) {
|
||||||
|
apply_label_new->setText (QString ());
|
||||||
|
} else if (marked == 1) {
|
||||||
|
apply_label_new->setText (tr ("One package selected"));
|
||||||
|
} else if (marked > 1) {
|
||||||
|
apply_label_new->setText (tr ("%1 packages selected").arg (marked));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_button->setEnabled (marked > 0);
|
model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
if (marked == 0) {
|
if (model) {
|
||||||
apply_label->setText (QString ());
|
|
||||||
} else if (marked == 1) {
|
int marked = 0;
|
||||||
apply_label->setText (tr ("One package selected"));
|
|
||||||
} else if (marked > 1) {
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
apply_label->setText (tr ("%1 packages selected").arg (marked));
|
--i;
|
||||||
|
QModelIndex index = model->index (i, 0, QModelIndex ());
|
||||||
|
SaltGrain *g = model->grain_from_index (index);
|
||||||
|
if (g && model->is_marked (g->name ())) {
|
||||||
|
marked += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_update_button->setEnabled (marked > 0);
|
||||||
|
if (marked == 0) {
|
||||||
|
apply_label_update->setText (QString ());
|
||||||
|
} else if (marked == 1) {
|
||||||
|
apply_label_update->setText (tr ("One package selected"));
|
||||||
|
} else if (marked > 1) {
|
||||||
|
apply_label_update->setText (tr ("%1 packages selected").arg (marked));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,12 +455,20 @@ SaltManagerDialog::apply ()
|
||||||
{
|
{
|
||||||
BEGIN_PROTECTED
|
BEGIN_PROTECTED
|
||||||
|
|
||||||
|
bool update = (sender () == apply_update_button);
|
||||||
|
|
||||||
lay::SaltDownloadManager manager;
|
lay::SaltDownloadManager manager;
|
||||||
|
|
||||||
bool any = false;
|
bool any = false;
|
||||||
|
|
||||||
// fetch all marked grains and register for download
|
// fetch all marked grains and register for download
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
SaltModel *model;
|
||||||
|
if (update) {
|
||||||
|
model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
|
} else {
|
||||||
|
model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
|
}
|
||||||
|
|
||||||
if (model) {
|
if (model) {
|
||||||
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
--i;
|
--i;
|
||||||
|
|
@ -331,13 +482,21 @@ BEGIN_PROTECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! any) {
|
if (! any) {
|
||||||
throw tl::Exception (tl::to_string (tr ("No packages marked for installation or update")));
|
if (update) {
|
||||||
|
throw tl::Exception (tl::to_string (tr ("No packages marked for update")));
|
||||||
|
} else {
|
||||||
|
throw tl::Exception (tl::to_string (tr ("No packages marked for installation")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.compute_dependencies (*mp_salt, *mp_salt_mine);
|
manager.compute_dependencies (*mp_salt, m_salt_mine);
|
||||||
|
|
||||||
if (manager.show_confirmation_dialog (this, *mp_salt)) {
|
if (manager.show_confirmation_dialog (this, *mp_salt)) {
|
||||||
unmark_all ();
|
if (update) {
|
||||||
|
unmark_all_update ();
|
||||||
|
} else {
|
||||||
|
unmark_all_new ();
|
||||||
|
}
|
||||||
manager.execute (*mp_salt);
|
manager.execute (*mp_salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,9 +585,35 @@ SaltManagerDialog::salt_changed ()
|
||||||
void
|
void
|
||||||
SaltManagerDialog::salt_mine_about_to_change ()
|
SaltManagerDialog::salt_mine_about_to_change ()
|
||||||
{
|
{
|
||||||
SaltModel *mine_model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
SaltModel *model;
|
||||||
tl_assert (mine_model != 0);
|
|
||||||
mine_model->begin_update ();
|
model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
|
tl_assert (model != 0);
|
||||||
|
model->begin_update ();
|
||||||
|
|
||||||
|
model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
|
tl_assert (model != 0);
|
||||||
|
model->begin_update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaltManagerDialog::refresh ()
|
||||||
|
{
|
||||||
|
BEGIN_PROTECTED
|
||||||
|
|
||||||
|
if (! m_salt_mine_url.empty ()) {
|
||||||
|
|
||||||
|
tl::log << tl::to_string (tr ("Downloading package repository from %1").arg (tl::to_qstring (m_salt_mine_url)));
|
||||||
|
|
||||||
|
lay::Salt new_mine;
|
||||||
|
new_mine.load (m_salt_mine_url);
|
||||||
|
m_salt_mine = new_mine;
|
||||||
|
|
||||||
|
salt_mine_changed ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
END_PROTECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -443,15 +628,11 @@ SaltManagerDialog::update_models ()
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_view->model ());
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_view->model ());
|
||||||
tl_assert (model != 0);
|
tl_assert (model != 0);
|
||||||
|
|
||||||
// NOTE: the disabling of the event handler prevents us from
|
|
||||||
// letting the model connect to the salt's signal directly.
|
|
||||||
m_current_changed_enabled = false;
|
|
||||||
|
|
||||||
model->clear_messages ();
|
model->clear_messages ();
|
||||||
|
|
||||||
// Establish a message saying that an update is available
|
// Establish a message saying that an update is available
|
||||||
for (Salt::flat_iterator g = mp_salt->begin_flat (); g != mp_salt->end_flat (); ++g) {
|
for (Salt::flat_iterator g = mp_salt->begin_flat (); g != mp_salt->end_flat (); ++g) {
|
||||||
SaltGrain *gm = mp_salt_mine->grain_by_name ((*g)->name ());
|
SaltGrain *gm = m_salt_mine.grain_by_name ((*g)->name ());
|
||||||
if (gm && SaltGrain::compare_versions (gm->version (), (*g)->version ()) > 0) {
|
if (gm && SaltGrain::compare_versions (gm->version (), (*g)->version ()) > 0) {
|
||||||
model->set_message ((*g)->name (), SaltModel::Warning, tl::to_string (tr ("An update to version %1 is available").arg (tl::to_qstring (gm->version ()))));
|
model->set_message ((*g)->name (), SaltModel::Warning, tl::to_string (tr ("An update to version %1 is available").arg (tl::to_qstring (gm->version ()))));
|
||||||
}
|
}
|
||||||
|
|
@ -459,8 +640,6 @@ SaltManagerDialog::update_models ()
|
||||||
|
|
||||||
model->update ();
|
model->update ();
|
||||||
|
|
||||||
m_current_changed_enabled = true;
|
|
||||||
|
|
||||||
if (mp_salt->is_empty ()) {
|
if (mp_salt->is_empty ()) {
|
||||||
|
|
||||||
list_stack->setCurrentIndex (1);
|
list_stack->setCurrentIndex (1);
|
||||||
|
|
@ -478,40 +657,59 @@ SaltManagerDialog::update_models ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SaltModel *mine_model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
SaltModel *mine_model;
|
||||||
tl_assert (mine_model != 0);
|
|
||||||
|
|
||||||
// NOTE: the disabling of the event handler prevents us from
|
mine_model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
// letting the model connect to the salt's signal directly.
|
tl_assert (mine_model != 0);
|
||||||
m_current_changed_enabled = false;
|
|
||||||
|
|
||||||
mine_model->clear_order ();
|
mine_model->clear_order ();
|
||||||
mine_model->clear_messages ();
|
mine_model->clear_messages ();
|
||||||
mine_model->enable_all ();
|
mine_model->enable_all ();
|
||||||
|
|
||||||
|
bool has_warning = false;
|
||||||
|
|
||||||
// Establish a message saying that an update is available
|
// Establish a message saying that an update is available
|
||||||
for (Salt::flat_iterator g = mp_salt->begin_flat (); g != mp_salt->end_flat (); ++g) {
|
for (Salt::flat_iterator g = mp_salt->begin_flat (); g != mp_salt->end_flat (); ++g) {
|
||||||
SaltGrain *gm = mp_salt_mine->grain_by_name ((*g)->name ());
|
SaltGrain *gm = m_salt_mine.grain_by_name ((*g)->name ());
|
||||||
if (gm && SaltGrain::compare_versions (gm->version (), (*g)->version ()) > 0) {
|
if (gm && SaltGrain::compare_versions (gm->version (), (*g)->version ()) > 0) {
|
||||||
|
has_warning = true;
|
||||||
mine_model->set_message ((*g)->name (), SaltModel::Warning, tl::to_string (tr ("The installed version is outdated (%1)").arg (tl::to_qstring ((*g)->version ()))));
|
mine_model->set_message ((*g)->name (), SaltModel::Warning, tl::to_string (tr ("The installed version is outdated (%1)").arg (tl::to_qstring ((*g)->version ()))));
|
||||||
mine_model->set_order ((*g)->name (), -1);
|
mine_model->set_order ((*g)->name (), -1);
|
||||||
} else if (gm) {
|
} else if (gm) {
|
||||||
mine_model->set_message ((*g)->name (), SaltModel::None, tl::to_string (tr ("This package is already installed and up to date")));
|
mine_model->set_message ((*g)->name (), SaltModel::None, tl::to_string (tr ("This package is up to date")));
|
||||||
mine_model->set_order ((*g)->name (), 1);
|
mine_model->set_order ((*g)->name (), 1);
|
||||||
mine_model->set_enabled ((*g)->name (), false);
|
mine_model->set_enabled ((*g)->name (), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mine_model->update ();
|
if (has_warning) {
|
||||||
|
mode_tab->setTabIcon (1, QIcon (":/warn_16.png"));
|
||||||
|
} else {
|
||||||
|
mode_tab->setTabIcon (1, QIcon ());
|
||||||
|
}
|
||||||
|
|
||||||
m_current_changed_enabled = true;
|
mine_model->update ();
|
||||||
|
|
||||||
// select the first grain
|
// select the first grain
|
||||||
if (mine_model->rowCount (QModelIndex ()) > 0) {
|
if (mine_model->rowCount (QModelIndex ()) > 0) {
|
||||||
salt_mine_view->setCurrentIndex (mine_model->index (0, 0, QModelIndex ()));
|
salt_mine_view_update->setCurrentIndex (mine_model->index (0, 0, QModelIndex ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mine_current_changed ();
|
mine_model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
|
tl_assert (mine_model != 0);
|
||||||
|
|
||||||
|
mine_model->clear_order ();
|
||||||
|
mine_model->clear_messages ();
|
||||||
|
mine_model->enable_all ();
|
||||||
|
mine_model->update ();
|
||||||
|
|
||||||
|
// select the first grain
|
||||||
|
if (mine_model->rowCount (QModelIndex ()) > 0) {
|
||||||
|
salt_mine_view_new->setCurrentIndex (mine_model->index (0, 0, QModelIndex ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
mine_new_current_changed ();
|
||||||
|
mine_update_current_changed ();
|
||||||
current_changed ();
|
current_changed ();
|
||||||
update_apply_state ();
|
update_apply_state ();
|
||||||
}
|
}
|
||||||
|
|
@ -539,20 +737,56 @@ SaltManagerDialog::current_grain ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::mine_current_changed ()
|
SaltManagerDialog::mine_update_current_changed ()
|
||||||
{
|
{
|
||||||
|
|
||||||
BEGIN_PROTECTED
|
BEGIN_PROTECTED
|
||||||
|
|
||||||
SaltGrain *g = mine_current_grain ();
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_update->model ());
|
||||||
|
tl_assert (model != 0);
|
||||||
|
SaltGrain *g = model->grain_from_index (salt_mine_view_update->currentIndex ());
|
||||||
|
|
||||||
|
details_update_frame->setEnabled (g != 0);
|
||||||
|
|
||||||
|
QString html;
|
||||||
|
SaltGrain *remote_grain = get_remote_grain_info (g, html);
|
||||||
|
|
||||||
|
m_remote_update_grain.reset (remote_grain);
|
||||||
|
details_update_text->set_grain (remote_grain);
|
||||||
|
details_update_text->setHtml (html);
|
||||||
|
|
||||||
|
END_PROTECTED
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaltManagerDialog::mine_new_current_changed ()
|
||||||
|
{
|
||||||
|
BEGIN_PROTECTED
|
||||||
|
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view_new->model ());
|
||||||
|
tl_assert (model != 0);
|
||||||
|
SaltGrain *g = model->grain_from_index (salt_mine_view_new->currentIndex ());
|
||||||
|
|
||||||
details_new_frame->setEnabled (g != 0);
|
details_new_frame->setEnabled (g != 0);
|
||||||
|
|
||||||
|
QString html;
|
||||||
|
SaltGrain *remote_grain = get_remote_grain_info (g, html);
|
||||||
|
|
||||||
|
m_remote_new_grain.reset (remote_grain);
|
||||||
|
details_new_text->set_grain (remote_grain);
|
||||||
|
details_new_text->setHtml (html);
|
||||||
|
|
||||||
|
END_PROTECTED
|
||||||
|
}
|
||||||
|
|
||||||
|
lay::SaltGrain *
|
||||||
|
SaltManagerDialog::get_remote_grain_info (lay::SaltGrain *g, QString &html)
|
||||||
|
{
|
||||||
if (! g) {
|
if (! g) {
|
||||||
details_new_text->set_grain (0);
|
return 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_remote_grain.reset (0);
|
std::auto_ptr<lay::SaltGrain> remote_grain;
|
||||||
|
remote_grain.reset (0);
|
||||||
|
|
||||||
// Download actual grain definition file
|
// Download actual grain definition file
|
||||||
try {
|
try {
|
||||||
|
|
@ -561,7 +795,7 @@ BEGIN_PROTECTED
|
||||||
throw tl::Exception (tl::to_string (tr ("No download link available")));
|
throw tl::Exception (tl::to_string (tr ("No download link available")));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString text = tr (
|
html = tr (
|
||||||
"<html>"
|
"<html>"
|
||||||
"<body>"
|
"<body>"
|
||||||
"<font color=\"#c0c0c0\">"
|
"<font color=\"#c0c0c0\">"
|
||||||
|
|
@ -573,30 +807,26 @@ BEGIN_PROTECTED
|
||||||
)
|
)
|
||||||
.arg (tl::to_qstring (SaltGrain::spec_url (g->url ())));
|
.arg (tl::to_qstring (SaltGrain::spec_url (g->url ())));
|
||||||
|
|
||||||
details_new_text->setHtml (text);
|
|
||||||
|
|
||||||
QApplication::processEvents (QEventLoop::ExcludeUserInputEvents);
|
QApplication::processEvents (QEventLoop::ExcludeUserInputEvents);
|
||||||
|
|
||||||
tl::InputStream stream (SaltGrain::spec_url (g->url ()));
|
tl::InputStream stream (SaltGrain::spec_url (g->url ()));
|
||||||
|
|
||||||
m_remote_grain.reset (new SaltGrain ());
|
remote_grain.reset (new SaltGrain ());
|
||||||
m_remote_grain->load (stream);
|
remote_grain->load (stream);
|
||||||
m_remote_grain->set_url (g->url ());
|
remote_grain->set_url (g->url ());
|
||||||
|
|
||||||
if (g->name () != m_remote_grain->name ()) {
|
if (g->name () != remote_grain->name ()) {
|
||||||
throw tl::Exception (tl::to_string (tr ("Name mismatch between repository and actual package (repository: %1, package: %2)").arg (tl::to_qstring (g->name ())).arg (tl::to_qstring (m_remote_grain->name ()))));
|
throw tl::Exception (tl::to_string (tr ("Name mismatch between repository and actual package (repository: %1, package: %2)").arg (tl::to_qstring (g->name ())).arg (tl::to_qstring (remote_grain->name ()))));
|
||||||
}
|
}
|
||||||
if (SaltGrain::compare_versions (g->version (), m_remote_grain->version ()) != 0) {
|
if (SaltGrain::compare_versions (g->version (), remote_grain->version ()) != 0) {
|
||||||
throw tl::Exception (tl::to_string (tr ("Version mismatch between repository and actual package (repository: %1, package: %2)").arg (tl::to_qstring (g->version ())).arg (tl::to_qstring (m_remote_grain->version ()))));
|
throw tl::Exception (tl::to_string (tr ("Version mismatch between repository and actual package (repository: %1, package: %2)").arg (tl::to_qstring (g->version ())).arg (tl::to_qstring (remote_grain->version ()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
details_new_text->set_grain (m_remote_grain.get ());
|
|
||||||
|
|
||||||
} catch (tl::Exception &ex) {
|
} catch (tl::Exception &ex) {
|
||||||
|
|
||||||
m_remote_grain.reset (0);
|
remote_grain.reset (0);
|
||||||
|
|
||||||
QString text = tr (
|
html = tr (
|
||||||
"<html>"
|
"<html>"
|
||||||
"<body>"
|
"<body>"
|
||||||
"<font color=\"#ff0000\">"
|
"<font color=\"#ff0000\">"
|
||||||
|
|
@ -610,18 +840,9 @@ BEGIN_PROTECTED
|
||||||
.arg (tl::to_qstring (SaltGrain::spec_url (g->url ())))
|
.arg (tl::to_qstring (SaltGrain::spec_url (g->url ())))
|
||||||
.arg (tl::to_qstring (tl::escaped_to_html (ex.msg ())));
|
.arg (tl::to_qstring (tl::escaped_to_html (ex.msg ())));
|
||||||
|
|
||||||
details_new_text->setHtml (text);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
END_PROTECTED
|
return remote_grain.release ();
|
||||||
}
|
|
||||||
|
|
||||||
lay::SaltGrain *
|
|
||||||
SaltManagerDialog::mine_current_grain ()
|
|
||||||
{
|
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_mine_view->model ());
|
|
||||||
return model ? model->grain_from_index (salt_mine_view->currentIndex ()) : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#define HDR_laySaltManagerDialog
|
#define HDR_laySaltManagerDialog
|
||||||
|
|
||||||
#include "ui_SaltManagerDialog.h"
|
#include "ui_SaltManagerDialog.h"
|
||||||
|
#include "laySalt.h"
|
||||||
#include "tlDeferredExecution.h"
|
#include "tlDeferredExecution.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
@ -32,8 +33,6 @@
|
||||||
namespace lay
|
namespace lay
|
||||||
{
|
{
|
||||||
|
|
||||||
class Salt;
|
|
||||||
class SaltGrain;
|
|
||||||
class SaltGrainPropertiesDialog;
|
class SaltGrainPropertiesDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,7 +47,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
SaltManagerDialog (QWidget *parent, lay::Salt *salt, lay::Salt *salt_mine);
|
SaltManagerDialog (QWidget *parent, lay::Salt *salt, const std::string &salt_mine_url);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,9 +76,14 @@ private slots:
|
||||||
void current_changed ();
|
void current_changed ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the currently selected package from the salt mine has changed
|
* @brief Called when the currently selected package from the update page has changed
|
||||||
*/
|
*/
|
||||||
void mine_current_changed ();
|
void mine_update_current_changed ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when the currently selected package from the new installation page has changed
|
||||||
|
*/
|
||||||
|
void mine_new_current_changed ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the "edit" button is pressed
|
* @brief Called when the "edit" button is pressed
|
||||||
|
|
@ -117,31 +121,54 @@ private slots:
|
||||||
void search_text_changed (const QString &text);
|
void search_text_changed (const QString &text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called to show the marked items only
|
* @brief Called to show the marked items only (new packages tab)
|
||||||
*/
|
*/
|
||||||
void show_marked_only ();
|
void show_marked_only_new ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called to show all items again
|
* @brief Called to show all items again (new packages tab)
|
||||||
*/
|
*/
|
||||||
void show_all ();
|
void show_all_new ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called to unmark all items
|
* @brief Called to unmark all items (new packages tab)
|
||||||
*/
|
*/
|
||||||
void unmark_all ();
|
void unmark_all_new ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called to show the marked items only (update packages tab)
|
||||||
|
*/
|
||||||
|
void show_marked_only_update ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called to show all items again (update packages tab)
|
||||||
|
*/
|
||||||
|
void show_all_update ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called to unmark all items (update packages tab)
|
||||||
|
*/
|
||||||
|
void unmark_all_update ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reloads the salt mine
|
||||||
|
*/
|
||||||
|
void refresh ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Salt *mp_salt, *mp_salt_mine;
|
Salt *mp_salt;
|
||||||
std::auto_ptr<SaltGrain> m_remote_grain;
|
Salt m_salt_mine;
|
||||||
bool m_current_changed_enabled;
|
std::string m_salt_mine_url;
|
||||||
|
std::auto_ptr<SaltGrain> m_remote_update_grain;
|
||||||
|
std::auto_ptr<SaltGrain> m_remote_new_grain;
|
||||||
SaltGrainPropertiesDialog *mp_properties_dialog;
|
SaltGrainPropertiesDialog *mp_properties_dialog;
|
||||||
tl::DeferredMethod<SaltManagerDialog> dm_update_models;
|
tl::DeferredMethod<SaltManagerDialog> dm_update_models;
|
||||||
|
int m_current_tab;
|
||||||
|
|
||||||
SaltGrain *current_grain ();
|
SaltGrain *current_grain ();
|
||||||
SaltGrain *mine_current_grain ();
|
|
||||||
void update_models ();
|
void update_models ();
|
||||||
void update_apply_state ();
|
void update_apply_state ();
|
||||||
|
SaltGrain *get_remote_grain_info (lay::SaltGrain *g, QString &html);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,10 @@ SaltItemDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelInde
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SaltModel::SaltModel (QObject *parent, lay::Salt *salt)
|
SaltModel::SaltModel (QObject *parent, lay::Salt *salt, lay::Salt *salt_filtered, bool salt_exclude)
|
||||||
: QAbstractItemModel (parent), mp_salt (salt), m_in_update (false)
|
: QAbstractItemModel (parent), mp_salt (salt),
|
||||||
|
mp_salt_filtered (salt_filtered), m_salt_exclude (salt_exclude),
|
||||||
|
m_in_update (false)
|
||||||
{
|
{
|
||||||
create_ordered_list ();
|
create_ordered_list ();
|
||||||
}
|
}
|
||||||
|
|
@ -389,6 +391,10 @@ SaltModel::create_ordered_list ()
|
||||||
if (m_display_order.empty ()) {
|
if (m_display_order.empty ()) {
|
||||||
|
|
||||||
for (Salt::flat_iterator i = mp_salt->begin_flat (); i != mp_salt->end_flat (); ++i) {
|
for (Salt::flat_iterator i = mp_salt->begin_flat (); i != mp_salt->end_flat (); ++i) {
|
||||||
|
// filter the grains by looking them up in the reference salt
|
||||||
|
if (mp_salt_filtered && (mp_salt_filtered->grain_by_name ((*i)->name ()) != 0) == m_salt_exclude) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
m_ordered_grains.push_back (*i);
|
m_ordered_grains.push_back (*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,6 +412,10 @@ SaltModel::create_ordered_list ()
|
||||||
|
|
||||||
for (int o = min_order; o <= max_order; ++o) {
|
for (int o = min_order; o <= max_order; ++o) {
|
||||||
for (Salt::flat_iterator i = mp_salt->begin_flat (); i != mp_salt->end_flat (); ++i) {
|
for (Salt::flat_iterator i = mp_salt->begin_flat (); i != mp_salt->end_flat (); ++i) {
|
||||||
|
// filter the grains by looking them up in the reference salt
|
||||||
|
if (mp_salt_filtered && (mp_salt_filtered->grain_by_name ((*i)->name ()) != 0) == m_salt_exclude) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
std::map<std::string, int>::const_iterator d = m_display_order.find ((*i)->name ());
|
std::map<std::string, int>::const_iterator d = m_display_order.find ((*i)->name ());
|
||||||
int oi = 0;
|
int oi = 0;
|
||||||
if (d != m_display_order.end ()) {
|
if (d != m_display_order.end ()) {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
SaltModel (QObject *parent, lay::Salt *salt);
|
SaltModel (QObject *parent, lay::Salt *salt, Salt *salt_filtered = 0, bool salt_exclude = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Implementation of the QAbstractItemModel interface
|
* @brief Implementation of the QAbstractItemModel interface
|
||||||
|
|
@ -170,7 +170,8 @@ public:
|
||||||
void clear_order ();
|
void clear_order ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lay::Salt *mp_salt;
|
lay::Salt *mp_salt, *mp_salt_filtered;
|
||||||
|
bool m_salt_exclude;
|
||||||
std::set<std::string> m_marked;
|
std::set<std::string> m_marked;
|
||||||
std::set<std::string> m_disabled;
|
std::set<std::string> m_disabled;
|
||||||
std::map<std::string, std::pair<Severity, std::string> > m_messages;
|
std::map<std::string, std::pair<Severity, std::string> > m_messages;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue