diff --git a/Code/qtiplot/MantidQt/MantidWidgets/MantidWidgets.pro b/Code/qtiplot/MantidQt/MantidWidgets/MantidWidgets.pro index 5fc39b85e995cae9f6b7b8d576554bef1c75837c..da0fd395f804293b91378edad6c9bc0ec6ebaaad 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/MantidWidgets.pro +++ b/Code/qtiplot/MantidQt/MantidWidgets/MantidWidgets.pro @@ -32,7 +32,9 @@ SOURCES = \ $$SRCDIR/MWDiagCalcs.cpp \ $$SRCDIR/SaveWorkspaces.cpp \ $$SRCDIR/ICatSearch.cpp \ - $$SRCDIR/ICatInvestigation.cpp + $$SRCDIR/ICatInvestigation.cpp \ + $$SRCDIR/ICatMyDataSearch.cpp + HEADERS = \ $$HEADERDIR/MantidWidget.h \ @@ -44,7 +46,8 @@ HEADERS = \ $$HEADERDIR/MWDiagCalcs.h \ $$HEADERDIR/SaveWorkspaces.h \ $$HEADERDIR/ICatSearch.h \ - $$HEADERDIR/ICatInvestigation.h + $$HEADERDIR/ICatInvestigation.h \ + $$HEADERDIR/ICatMyDataSearch.h UI_DIR = $$HEADERDIR @@ -52,7 +55,8 @@ FORMS = \ $$HEADERDIR/MWRunFiles.ui \ $$HEADERDIR/MWDiag.ui \ $$HEADERDIR/ICatSearch.ui \ - $$HEADERDIR/ICatInvestigation.ui + $$HEADERDIR/ICatInvestigation.ui \ + $$HEADERDIR/ICatMyDataSearch.ui UI_HEADERS_DIR = "$$MANTIDQTINCLUDES/MantidQtMantidWidgets" diff --git a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.h b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.h index 9dd7d08c7b843d0f473d88811aea5629a086207b..7e2a5a119eddbe61e385dee463f78085833d8ec8 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.h +++ b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.h @@ -8,8 +8,6 @@ #include "MantidQtMantidWidgets/MantidWidget.h" #include "MantidAPI/ITableWorkspace.h" #include "WidgetDllOption.h" -#include<QObject> -#include<QEvent> namespace MantidQt { @@ -42,13 +40,13 @@ private: Mantid::API::ITableWorkspace_sptr executeGetdataSets(); /// Poulates the data files tree widget - void populateinvestigationWidget(Mantid::API::ITableWorkspace_sptr & ws_sptr); + void populateinvestigationWidget(Mantid::API::ITableWorkspace_sptr ws_sptr,const QString& type); /// executes the downlaod file algorithm - bool executeDownloadDataFile(const QString& fileName,QString& fileLoc); + bool executeDownloadDataFiles(const std::vector<std::string>& fileNames,std::vector<std::string>& fileLocs); /// get the selected file name - void getSelctedFileName(QString& fileName ); + void getSelectedFileNames(std::vector<std::string>& fileNames ); /// checks the file is of raw extn bool isRawFile(const QString& fileName); @@ -68,8 +66,10 @@ private: bool execute(const QString& algName,const int& version,const QString& filepath,const QString& wsName); /// This method sets the isis archive location - void setisisarchiveFileLocation(const QString& fileLoc); + void setICatFileLocation(const std::vector<std::string>& fileLocs); + /// This method loads raw/nexus data + bool loadData( const QString& filePath); private slots: /// investigation Clicked @@ -84,10 +84,13 @@ private: void tableItemSelected(QTableWidgetItem* item); /// load button clicked void onLoad(); + /// select all files button clciked + void onSelectAllFiles(); + /// if data file checkbox selected + bool isDataFilesChecked(); + /// This method checks the selected data file exis in the downlaoded list + bool isFileExistsInDownlodedList(const std::string& selectedFile,std::string& loadPath); - - //bool eventFilter(QObject *obj, QEvent *event); - private: //The form generated by Qt Designer Ui::ICatInvestigation m_uiForm; @@ -102,10 +105,14 @@ private: QString m_Instrument; /// data files workspace Mantid::API::ITableWorkspace_sptr m_datafilesws_sptr; + /// filtered data files workspace pointer + Mantid::API::ITableWorkspace_sptr m_filteredws_sptr; /// shared pointer to datasets workspace Mantid::API::ITableWorkspace_sptr m_datasetsws_sptr; - /// isis archive location of the string - QString m_archiveLoc; + /// isis archive/mantid-icat downlaod location string + //QString m_downloadedFileList; + + std::vector<std::string> m_downloadedFileList; }; diff --git a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.ui b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.ui index 8f9f81b28bfa7bad006f8ec757459451f9016d5e..3122f48bfe006d884068b1c3d1a44a2e5cce083d 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.ui +++ b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatInvestigation.ui @@ -5,177 +5,169 @@ <rect> <x>0</x> <y>0</y> - <width>679</width> + <width>698</width> <height>501</height> </rect> </property> <property name="windowTitle" > <string>Investigation Data</string> </property> - <widget class="QTreeWidget" name="invsttreeWidget" > - <property name="geometry" > - <rect> - <x>11</x> - <y>35</y> - <width>241</width> - <height>411</height> - </rect> - </property> - <property name="horizontalScrollBarPolicy" > - <enum>Qt::ScrollBarAsNeeded</enum> - </property> - <property name="autoScrollMargin" > - <number>9</number> - </property> - <property name="alternatingRowColors" > - <bool>false</bool> - </property> - <column> - <property name="text" > - <string>Data</string> - </property> - </column> - </widget> - <widget class="QTableWidget" name="invsttableWidget" > - <property name="geometry" > - <rect> - <x>255</x> - <y>35</y> - <width>413</width> - <height>411</height> - </rect> - </property> - <property name="font" > - <font> - <weight>50</weight> - <bold>false</bold> - </font> - </property> - <property name="alternatingRowColors" > - <bool>true</bool> - </property> - <property name="selectionMode" > - <enum>QAbstractItemView::SingleSelection</enum> - </property> - <property name="selectionBehavior" > - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="sortingEnabled" > - <bool>true</bool> - </property> - <column> - <property name="text" > - <string>Name</string> - </property> - </column> - <column> - <property name="text" > - <string>File Size</string> - </property> - </column> - <column> - <property name="text" > - <string>File Id</string> - </property> - </column> - <column> - <property name="text" > - <string>Format</string> - </property> - </column> - <column> - <property name="text" > - <string>Format Version</string> - </property> - </column> - <column> - <property name="text" > - <string>Format Type</string> - </property> - </column> - <column> - <property name="text" > - <string>Create Time</string> - </property> - </column> - </widget> - <widget class="QLabel" name="invstlabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>14</y> - <width>658</width> - <height>20</height> - </rect> - </property> - <property name="frameShape" > - <enum>QFrame::Box</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Sunken</enum> - </property> - <property name="text" > - <string/> - </property> - </widget> - <widget class="QCheckBox" name="loadcheckBox" > - <property name="geometry" > - <rect> - <x>10</x> - <y>460</y> - <width>151</width> - <height>18</height> - </rect> - </property> - <property name="text" > - <string>Controlled loading of data</string> - </property> - </widget> - <widget class="QWidget" name="layoutWidget" > - <property name="geometry" > - <rect> - <x>348</x> - <y>460</y> - <width>320</width> - <height>25</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2" > - <item> - <widget class="QPushButton" name="okButton" > + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" colspan="5" > + <widget class="QLabel" name="invstlabel" > + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Sunken</enum> + </property> + <property name="text" > + <string/> + </property> + </widget> + </item> + <item row="1" column="0" colspan="3" > + <widget class="QTreeWidget" name="invsttreeWidget" > + <property name="horizontalScrollBarPolicy" > + <enum>Qt::ScrollBarAsNeeded</enum> + </property> + <property name="autoScrollMargin" > + <number>9</number> + </property> + <property name="alternatingRowColors" > + <bool>false</bool> + </property> + <column> <property name="text" > - <string>Ok</string> + <string>Data</string> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton" > + </column> + </widget> + </item> + <item row="1" column="3" colspan="2" > + <widget class="QTableWidget" name="invsttableWidget" > + <property name="font" > + <font> + <weight>50</weight> + <bold>false</bold> + </font> + </property> + <property name="styleSheet" > + <string notr="true" >alternate-background-color: rgb(216, 225, 255);</string> + </property> + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + <property name="selectionMode" > + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + <property name="selectionBehavior" > + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="sortingEnabled" > + <bool>false</bool> + </property> + <property name="cornerButtonEnabled" > + <bool>true</bool> + </property> + <column> <property name="text" > - <string>Cancel</string> + <string>Name</string> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="downloadButton" > + </column> + <column> <property name="text" > - <string>Download</string> + <string>File Size (B)</string> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="LoadButton" > + </column> + <column> <property name="text" > - <string>Load</string> + <string>File Id</string> </property> - </widget> - </item> - </layout> - </widget> - <zorder>layoutWidget</zorder> - <zorder>invsttreeWidget</zorder> - <zorder>invsttableWidget</zorder> - <zorder>invstlabel</zorder> - <zorder>loadcheckBox</zorder> + </column> + <column> + <property name="text" > + <string>Format</string> + </property> + </column> + <column> + <property name="text" > + <string>Format Version</string> + </property> + </column> + <column> + <property name="text" > + <string>Format Type</string> + </property> + </column> + <column> + <property name="text" > + <string>Create Time</string> + </property> + </column> + </widget> + </item> + <item row="2" column="0" > + <widget class="QPushButton" name="pushButton" > + <property name="text" > + <string>Help</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QCheckBox" name="loadcheckBox" > + <property name="text" > + <string>Controlled loading </string> + </property> + </widget> + </item> + <item row="2" column="2" colspan="2" > + <widget class="QCheckBox" name="dataFilescheckBox" > + <property name="text" > + <string> DataFiles</string> + </property> + </widget> + </item> + <item row="2" column="4" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QPushButton" name="selectallButton" > + <property name="text" > + <string>Select All Files</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="downloadButton" > + <property name="text" > + <string>Download</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="LoadButton" > + <property name="text" > + <string>Load</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="okButton" > + <property name="text" > + <string>Ok</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton" > + <property name="text" > + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> </widget> <tabstops> <tabstop>invsttreeWidget</tabstop> diff --git a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatMyDataSearch.h b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatMyDataSearch.h new file mode 100644 index 0000000000000000000000000000000000000000..5bff830b82c9e3fb9ff2edf880dd2cf32828ac98 --- /dev/null +++ b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatMyDataSearch.h @@ -0,0 +1,29 @@ +#ifndef MANTIDWIDGETS_ICATMYDATASEARCH_H_ +#define MANTIDWIDGETS_ICATMYDATASEARCH_H_ + +#include "MantidQtMantidWidgets/ui_ICatMyDataSearch.h" +#include "WidgetDllOption.h" +#include "MantidAPI/ITableWorkspace.h" + +namespace MantidQt +{ +namespace MantidWidgets +{ +class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS ICatMyDataSearch : public QWidget +{ + Q_OBJECT +public: + ICatMyDataSearch(QWidget*parent); + //~ICatMyDataSearch(); +signals: + ///this signal prints error messge to log window + void error(const QString&); +private: + Mantid::API::ITableWorkspace_sptr executeMyDataSearch(); +private: + Ui::Form m_uiForm; + +}; +} +} +#endif \ No newline at end of file diff --git a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatMyDataSearch.ui b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatMyDataSearch.ui new file mode 100644 index 0000000000000000000000000000000000000000..dc7518b596700d8d48c61e635cedf7fd18e34f8c --- /dev/null +++ b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatMyDataSearch.ui @@ -0,0 +1,97 @@ +<ui version="4.0" > + <class>Form</class> + <widget class="QWidget" name="Form" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>780</width> + <height>223</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="mydatalabel" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="text" > + <string/> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QTableWidget" name="myDatatableWidget" > + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + <column> + <property name="text" > + <string>InvestigationId</string> + </property> + </column> + <column> + <property name="text" > + <string>RbNumber</string> + </property> + </column> + <column> + <property name="text" > + <string>Title</string> + </property> + </column> + <column> + <property name="text" > + <string>Type</string> + </property> + </column> + <column> + <property name="text" > + <string>Instrument</string> + </property> + </column> + <column> + <property name="text" > + <string>Investigator</string> + </property> + </column> + <column> + <property name="text" > + <string>RunRange</string> + </property> + </column> + <column> + <property name="text" > + <string>Year</string> + </property> + </column> + <column> + <property name="text" > + <string>Abstract</string> + </property> + </column> + <column> + <property name="text" > + <string>Investigators First Name</string> + </property> + </column> + <column> + <property name="text" > + <string>Investigators Second Name</string> + </property> + </column> + <column> + <property name="text" > + <string>Samples Name</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.h b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.h index f9ab2796e660099d553575c126a4ff81b83e3545..8fbf169308ff44ac6b5eaa0dcc452e9b6b1747a1 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.h +++ b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.h @@ -7,13 +7,14 @@ //---------------------- //#include "MantidQtMantidWidgets/ui_ICatSearch.h" #include "MantidQtMantidWidgets/ui_ICatSearch.h" -#include "MantidQtMantidWidgets/MantidWidget.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidQtMantidWidgets/ICatInvestigation.h" #include "WidgetDllOption.h" #include<QObject> #include<QEvent> +#include <QListWidget> +#include <QCalendarWidget> namespace MantidQt { @@ -34,7 +35,6 @@ public: signals: void error(const QString&); - private: /// Initialize the layout virtual void initLayout(); @@ -44,13 +44,13 @@ private: Mantid::API::ITableWorkspace_sptr executeListInstruments(); ///get start and end run numbers void getRunValues(double& startRun,double& endRun); + ///get the user set start and end dates + void getDates(QString& startDate,QString& endDate); /// get the user selected instrument void getSelectedInstrument(QString& instrName); /// execute the algorithm Mantid::API::ITableWorkspace_sptr executeSearchByRunNumber(const double &startRun,const double &endRun,bool bCase,const std::string& instrName); - /// setting tool tips for all elements - void setToolTips(); /// this method populates the search result widget. void updatesearchResults(Mantid::API::ITableWorkspace_sptr & ws_sptr ); /// save settings to registry @@ -71,20 +71,31 @@ private slots: ///handler for search button void onSearch(); ///handler for cancel - void onCancel(); + void onClose(); + + //handler for OK button + void onOK(); /// void investigationSelected(QTableWidgetItem *); + ///start date changed + void getstartDate(const QDate& date ); + ///popup DateTime calender to select date + void popupCalender(); private: ///The form generated by Qt Designer Ui::ICatSearch m_uiForm; - - // Uii::ICatSearch1 m_uiform1; - + MantidQt::MantidWidgets::ICatInvestigation* m_invstWidget; - // QWidget* m_invstWidget; + QWidget* m_applicationWindow; + //pointer to object to identify starta nd end date tool button + QObject* m_sender; + + //pointer to calender object + QCalendarWidget* m_calendarWidget ; + }; diff --git a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.ui b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.ui index b37dfd3ec0f2bac0f2d681bd61ddb089615fc2ee..e3c035be438f0aa8e012e261a6632fe82fdab1ab 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.ui +++ b/Code/qtiplot/MantidQt/MantidWidgets/inc/ICatSearch.ui @@ -5,8 +5,8 @@ <rect> <x>0</x> <y>0</y> - <width>713</width> - <height>591</height> + <width>641</width> + <height>560</height> </rect> </property> <property name="windowTitle" > @@ -15,15 +15,18 @@ <widget class="QTableWidget" name="searchtableWidget" > <property name="geometry" > <rect> - <x>240</x> - <y>30</y> - <width>461</width> - <height>521</height> + <x>10</x> + <y>150</y> + <width>621</width> + <height>371</height> </rect> </property> <property name="toolTip" > <string>ICat Search Results Window</string> </property> + <property name="styleSheet" > + <string notr="true" >alternate-background-color: rgb(216, 225, 255);</string> + </property> <property name="alternatingRowColors" > <bool>true</bool> </property> @@ -74,190 +77,268 @@ </property> </column> </widget> + <widget class="QLabel" name="searchlabel" > + <property name="geometry" > + <rect> + <x>10</x> + <y>10</y> + <width>622</width> + <height>20</height> + </rect> + </property> + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Sunken</enum> + </property> + <property name="text" > + <string/> + </property> + </widget> <widget class="QTreeWidget" name="searchtreeWidget" > <property name="geometry" > <rect> <x>10</x> <y>30</y> - <width>231</width> - <height>521</height> + <width>621</width> + <height>121</height> </rect> </property> <property name="toolTip" > - <string>ICat Search Widget</string> + <string>ICat Search Box</string> </property> <property name="statusTip" > <string/> </property> <column> <property name="text" > - <string>Search Widget</string> + <string>Search Box</string> </property> </column> </widget> - <widget class="QGroupBox" name="searchgroupBox" > + <widget class="QLabel" name="enddateLabel" > <property name="geometry" > <rect> - <x>20</x> - <y>130</y> - <width>211</width> - <height>109</height> + <x>230</x> + <y>93</y> + <width>61</width> + <height>16</height> </rect> </property> - <property name="title" > - <string>SearchBox</string> - </property> - <widget class="QLabel" name="runNumberLabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>22</y> - <width>31</width> - <height>20</height> - </rect> - </property> - <property name="text" > - <string>Run#:</string> - </property> - </widget> - <widget class="QLineEdit" name="startRunEdit" > - <property name="geometry" > - <rect> - <x>47</x> - <y>21</y> - <width>63</width> - <height>20</height> - </rect> - </property> - <property name="toolTip" > - <string>Start Run Number</string> - </property> - </widget> - <widget class="QLineEdit" name="endRunEdit" > - <property name="geometry" > - <rect> - <x>133</x> - <y>20</y> - <width>63</width> - <height>20</height> - </rect> - </property> - <property name="toolTip" > - <string>End Run Number</string> - </property> - </widget> - <widget class="QLabel" name="instrumentLabel" > - <property name="geometry" > - <rect> - <x>10</x> - <y>50</y> - <width>116</width> - <height>20</height> - </rect> - </property> - <property name="text" > - <string>Instrument:</string> - </property> - </widget> - <widget class="QComboBox" name="instrmentBox" > - <property name="geometry" > - <rect> - <x>134</x> - <y>50</y> - <width>63</width> - <height>20</height> - </rect> - </property> - <property name="toolTip" > - <string>Instrument Box</string> - </property> - </widget> - <widget class="QCheckBox" name="casesensitiveBox" > - <property name="geometry" > - <rect> - <x>10</x> - <y>78</y> - <width>116</width> - <height>18</height> - </rect> - </property> - <property name="text" > - <string>Case Sensitive</string> - </property> - </widget> - <widget class="QPushButton" name="searchButton" > - <property name="geometry" > - <rect> - <x>134</x> - <y>77</y> - <width>63</width> - <height>23</height> - </rect> - </property> - <property name="text" > - <string>Search</string> - </property> - </widget> + <property name="text" > + <string>End Date:</string> + </property> </widget> - <widget class="QLabel" name="searchlabel" > + <widget class="QLineEdit" name="endRunEdit" > <property name="geometry" > <rect> - <x>9</x> - <y>9</y> - <width>693</width> + <x>140</x> + <y>60</y> + <width>70</width> <height>20</height> </rect> </property> - <property name="frameShape" > - <enum>QFrame::Box</enum> + <property name="toolTip" > + <string>End Run Number</string> </property> - <property name="frameShadow" > - <enum>QFrame::Sunken</enum> + </widget> + <widget class="QLineEdit" name="startdateLineEdit" > + <property name="geometry" > + <rect> + <x>300</x> + <y>60</y> + <width>70</width> + <height>20</height> + </rect> </property> <property name="text" > - <string/> + <string>DD/MM/YYYY</string> + </property> + </widget> + <widget class="QLineEdit" name="startRunEdit" > + <property name="geometry" > + <rect> + <x>59</x> + <y>60</y> + <width>70</width> + <height>20</height> + </rect> + </property> + <property name="toolTip" > + <string>Start Run Number</string> + </property> + </widget> + <widget class="QLabel" name="startdateLabel" > + <property name="geometry" > + <rect> + <x>230</x> + <y>63</y> + <width>61</width> + <height>16</height> + </rect> + </property> + <property name="text" > + <string>Start Date:</string> + </property> + </widget> + <widget class="QCheckBox" name="casesensitiveBox" > + <property name="geometry" > + <rect> + <x>490</x> + <y>90</y> + <width>111</width> + <height>18</height> + </rect> + </property> + <property name="toolTip" > + <string>Case Sensitive keyWord Search</string> + </property> + <property name="text" > + <string>Case Sensitive</string> + </property> + </widget> + <widget class="QLabel" name="runNumberLabel" > + <property name="geometry" > + <rect> + <x>14</x> + <y>61</y> + <width>31</width> + <height>20</height> + </rect> + </property> + <property name="text" > + <string>Run#:</string> + </property> + </widget> + <widget class="QToolButton" name="startdatetoolButton" > + <property name="geometry" > + <rect> + <x>380</x> + <y>60</y> + <width>25</width> + <height>20</height> + </rect> + </property> + <property name="text" > + <string>...</string> </property> </widget> - <widget class="QWidget" name="layoutWidget" > + <widget class="QLabel" name="instrumentLabel" > <property name="geometry" > <rect> - <x>543</x> - <y>560</y> - <width>158</width> - <height>25</height> + <x>14</x> + <y>90</y> + <width>61</width> + <height>20</height> + </rect> + </property> + <property name="text" > + <string>Instrument:</string> + </property> + </widget> + <widget class="QComboBox" name="instrmentBox" > + <property name="geometry" > + <rect> + <x>140</x> + <y>90</y> + <width>70</width> + <height>20</height> + </rect> + </property> + <property name="toolTip" > + <string>Instrument Box</string> + </property> + </widget> + <widget class="QLabel" name="keywordsLabel" > + <property name="geometry" > + <rect> + <x>420</x> + <y>62</y> + <width>71</width> + <height>16</height> + </rect> + </property> + <property name="text" > + <string>KeyWord(s):</string> + </property> + </widget> + <widget class="QLineEdit" name="enddateLineEdit" > + <property name="geometry" > + <rect> + <x>300</x> + <y>90</y> + <width>70</width> + <height>20</height> </rect> </property> - <layout class="QHBoxLayout" name="horizontalLayout" > - <item> - <widget class="QPushButton" name="okButton" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - <zorder>cancelButton</zorder> - <zorder>okButton</zorder> + <property name="text" > + <string>DD/MM/YYYY</string> + </property> + </widget> + <widget class="QToolButton" name="enddatetoolButton" > + <property name="geometry" > + <rect> + <x>380</x> + <y>90</y> + <width>25</width> + <height>20</height> + </rect> + </property> + <property name="text" > + <string>...</string> + </property> + </widget> + <widget class="QLineEdit" name="keywordslineEdit" > + <property name="geometry" > + <rect> + <x>490</x> + <y>60</y> + <width>131</width> + <height>20</height> + </rect> + </property> + </widget> + <widget class="QPushButton" name="searchButton" > + <property name="geometry" > + <rect> + <x>550</x> + <y>120</y> + <width>70</width> + <height>23</height> + </rect> + </property> + <property name="text" > + <string>Search</string> + </property> + </widget> + <widget class="QPushButton" name="helpButton" > + <property name="geometry" > + <rect> + <x>10</x> + <y>530</y> + <width>61</width> + <height>23</height> + </rect> + </property> + <property name="text" > + <string>Help</string> + </property> + </widget> + <widget class="QPushButton" name="closeButton" > + <property name="geometry" > + <rect> + <x>572</x> + <y>530</y> + <width>61</width> + <height>23</height> + </rect> + </property> + <property name="text" > + <string>Close</string> + </property> </widget> </widget> - <tabstops> - <tabstop>startRunEdit</tabstop> - <tabstop>endRunEdit</tabstop> - <tabstop>instrmentBox</tabstop> - <tabstop>casesensitiveBox</tabstop> - <tabstop>searchButton</tabstop> - <tabstop>okButton</tabstop> - <tabstop>cancelButton</tabstop> - <tabstop>searchtreeWidget</tabstop> - <tabstop>searchtableWidget</tabstop> - </tabstops> <resources/> <connections/> </ui> diff --git a/Code/qtiplot/MantidQt/MantidWidgets/src/ICatInvestigation.cpp b/Code/qtiplot/MantidQt/MantidWidgets/src/ICatInvestigation.cpp index d254b4dac9f5bd6040b0d3fb5afd93b13c5beee3..8178a80c0136b110f08fdf0afc10b38cbc3d26ae 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/src/ICatInvestigation.cpp +++ b/Code/qtiplot/MantidQt/MantidWidgets/src/ICatInvestigation.cpp @@ -2,7 +2,6 @@ // Includes //---------------------- #include "MantidQtMantidWidgets/ICatInvestigation.h" - #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/ITableWorkspace.h" @@ -10,9 +9,8 @@ #include "MantidAPI/TableRow.h" #include "MantidKernel/ConfigService.h" -#include<QStringList> #include<QHeaderView> -#include<QFont> + using namespace Mantid::API; using namespace MantidQt::MantidWidgets; @@ -23,12 +21,12 @@ using namespace MantidQt::MantidWidgets; ///Constructor ICatInvestigation::ICatInvestigation(long long investId,const QString &RbNumber,const QString &Title, const QString &Instrument,QWidget *par) :QWidget(par),m_invstId(investId), - m_RbNumber(RbNumber),m_Title(Title),m_Instrument(Instrument),m_archiveLoc("") + m_RbNumber(RbNumber),m_Title(Title),m_Instrument(Instrument),m_downloadedFileList() { initLayout(); m_uiForm.invsttableWidget->verticalHeader()->setVisible(false); - m_uiForm.LoadButton->setEnabled(false); - m_uiForm.downloadButton->setEnabled(false); + //m_uiForm.LoadButton->setEnabled(false); + //m_uiForm.downloadButton->setEnabled(false); populateInvestigationTreeWidget();//Tree on LHS of the display @@ -45,6 +43,7 @@ ICatInvestigation::ICatInvestigation(long long investId,const QString &RbNumber, connect(this,SIGNAL(error(const QString&)),parent()->parent(),SLOT(writetoLogWindow(const QString& ))); connect(this,SIGNAL(loadRawAsynch(const QString&,const QString&)),parent()->parent(),SLOT(executeLoadRawAsynch(const QString&,const QString& ))); connect(this,SIGNAL(loadNexusAsynch(const QString&,const QString&)),parent()->parent(),SLOT(executeLoadNexusAsynch(const QString&,const QString& ))); + connect(m_uiForm.selectallButton,SIGNAL(clicked()),this,SLOT(onSelectAllFiles())); } @@ -121,7 +120,6 @@ ITableWorkspace_sptr ICatInvestigation::executeGetdataFiles() try { alg = Mantid::API::AlgorithmManager::Instance().create(algName.toStdString(),version); - } catch(...) { @@ -130,6 +128,7 @@ ITableWorkspace_sptr ICatInvestigation::executeGetdataFiles() try { alg->setProperty("InvestigationId",m_invstId); + alg->setProperty("DataFiles",isDataFilesChecked()); alg->setPropertyValue("OutputWorkspace","insvestigation"); } catch(std::invalid_argument& e) @@ -137,15 +136,24 @@ ITableWorkspace_sptr ICatInvestigation::executeGetdataFiles() emit error(e.what()); return ws_sptr; } - alg->execute(); - if(!alg->isExecuted()) + + try { - return ws_sptr; + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } } - + catch(...) + { + return ws_sptr; + } + if(AnalysisDataService::Instance().doesExist("insvestigation")) + { ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> (AnalysisDataService::Instance().retrieve("insvestigation")); - + } return ws_sptr; } @@ -174,22 +182,33 @@ ITableWorkspace_sptr ICatInvestigation::executeGetdataSets() emit error(e.what()); return ws_sptr; } - alg->execute(); - if(!alg->isExecuted()) + + try { - return ws_sptr; + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } + } + catch(...) + { + return ws_sptr; + } + if(AnalysisDataService::Instance().doesExist("datasets")) + { + ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> + (AnalysisDataService::Instance().retrieve("datasets")); } - - ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> - (AnalysisDataService::Instance().retrieve("datasets")); return ws_sptr; } /**This method executes the GetdatFile algorithm used for getting the data file location or downloading the data file *@param fileName -name of the file to download - *@param fileLoc -archive location of the file + *@param fileLocs -archive location of the file */ -bool ICatInvestigation::executeDownloadDataFile(const QString& fileName,QString& fileLoc) +//bool ICatInvestigation::executeDownloadDataFile(const QString& fileName,QString& fileLoc) +bool ICatInvestigation::executeDownloadDataFiles(const std::vector<std::string>& fileNames,std::vector<std::string>& fileLocs) { // QString algName("GetDataFile"); @@ -211,7 +230,8 @@ bool ICatInvestigation::executeDownloadDataFile(const QString& fileName,QString& } try { - alg->setProperty("Filename",fileName.toStdString()); + + alg->setProperty("Filenames",fileNames); //alg->setProperty("InputWorkspace",m_datafilesws_sptr); alg->setPropertyValue("InputWorkspace","insvestigation"); } @@ -220,14 +240,27 @@ bool ICatInvestigation::executeDownloadDataFile(const QString& fileName,QString& emit error(e.what()); return false; } - alg->execute(); + /*alg->execute(); + if(!alg->isExecuted()) { - return false; + return false; + }*/ + try + { + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } + } + catch(...) + { + return false; } try { - fileLoc = QString::fromStdString(alg->getPropertyValue("FileLocation")); + fileLocs = alg->getProperty("FileLocations"); } catch (Mantid::Kernel::Exception::NotFoundError&e) { @@ -244,38 +277,55 @@ bool ICatInvestigation::executeDownloadDataFile(const QString& fileName,QString& */ void ICatInvestigation::investigationClicked(QTreeWidgetItem* item, int) { - QFont font; - font.setBold(true); + if(!item)return; + //QFont font; + //font.setBold(true); + //QString labelText; + //std::stringstream totalCount; if(!item->text(0).compare("Default")) - { - if(!m_datafilesws_sptr){ - m_datafilesws_sptr = executeGetdataFiles(); - - m_uiForm.invstlabel->clear(); - m_uiForm.invstlabel->setText("ICat Datafiles"); - m_uiForm.invstlabel->setAlignment(Qt::AlignHCenter); - m_uiForm.invstlabel->setFont(font); + { + if(isDataFilesChecked()) + { + if(!m_filteredws_sptr) + { + m_filteredws_sptr=executeGetdataFiles(); + } + populateinvestigationWidget(m_filteredws_sptr,"DataFiles"); + } + else + { + if(!m_datafilesws_sptr) + { + m_datafilesws_sptr = executeGetdataFiles(); + } + if(!m_datafilesws_sptr) return; + populateinvestigationWidget(m_datafilesws_sptr,"DataFiles"); } - populateinvestigationWidget(m_datafilesws_sptr); } - if(!item->text(0).compare("DataSets")) + else if(!item->text(0).compare("DataSets")) { if(!m_datasetsws_sptr){ m_datasetsws_sptr= executeGetdataSets(); - m_uiForm.invstlabel->clear(); - m_uiForm.invstlabel->setText("ICat Datasets"); - m_uiForm.invstlabel->setAlignment(Qt::AlignHCenter); - m_uiForm.invstlabel->setFont(font); + } - populateinvestigationWidget(m_datasetsws_sptr); + if(!m_datasetsws_sptr)return; + populateinvestigationWidget(m_datasetsws_sptr,"DataSets"); } + else if (item->text(0).compare(m_Title)) + { + } + } /**This method populates the investigation table widget + *@param bdataFiles -shared pointer to data files *@param ws_sptr - shared pointer to workspace */ -void ICatInvestigation::populateinvestigationWidget(Mantid::API::ITableWorkspace_sptr & ws_sptr) +void ICatInvestigation::populateinvestigationWidget(Mantid::API::ITableWorkspace_sptr dataws_sptr,const QString& type) { - if(!ws_sptr){return;} + if(!dataws_sptr){return;} + Mantid::API::ITableWorkspace_sptr ws_sptr(dataws_sptr); + //turn off sorting as per QT documentation + m_uiForm.invsttableWidget->setSortingEnabled(false); //below for loop for clearing the table widget on each mouse click,otherwise rows will be appended. // table widget clear() method is clearing only the item text,not removing the rows,columns @@ -285,10 +335,10 @@ void ICatInvestigation::populateinvestigationWidget(Mantid::API::ITableWorkspace { m_uiForm.invsttableWidget->removeRow(i); } - + m_uiForm.invsttableWidget->setRowCount(ws_sptr->rowCount()); for (int i=0;i<ws_sptr->rowCount();++i) { - m_uiForm.invsttableWidget->insertRow(i); + //m_uiForm.invsttableWidget->insertRow(i); //setting the row height of tableWidget m_uiForm.invsttableWidget->setRowHeight(i,20); } @@ -303,13 +353,14 @@ void ICatInvestigation::populateinvestigationWidget(Mantid::API::ITableWorkspace for(int j=0;j<ws_sptr->rowCount();++j) { - std::ostringstream ostr; - col_sptr->print(ostr,j); - - QTableWidgetItem *newItem = new QTableWidgetItem(QString::fromStdString(ostr.str())); - newItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - m_uiForm.invsttableWidget->setItem(j,i, newItem); - newItem->setToolTip(QString::fromStdString(ostr.str())); + std::ostringstream ostr; + col_sptr->print(ostr,j); + + QTableWidgetItem *newItem = new QTableWidgetItem(QString::fromStdString(ostr.str())); + newItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + m_uiForm.invsttableWidget->setItem(j,i, newItem); + newItem->setToolTip(QString::fromStdString(ostr.str())); + } } //setting table widget header labels from table workspace @@ -321,7 +372,20 @@ void ICatInvestigation::populateinvestigationWidget(Mantid::API::ITableWorkspace m_uiForm.invsttableWidget->horizontalHeaderItem(i)->setFont(font);; } //resizing the coluns based on data size - m_uiForm.invsttableWidget->resizeColumnsToContents (); + m_uiForm.invsttableWidget->resizeColumnsToContents(); + + QString labelText; + std::stringstream totalCount; + totalCount<<ws_sptr->rowCount(); + labelText="Data: "+QString::fromStdString(totalCount.str())+" "+type+" found"; + + m_uiForm.invstlabel->clear(); + m_uiForm.invstlabel->setText(labelText); + m_uiForm.invstlabel->setAlignment(Qt::AlignHCenter); + m_uiForm.invstlabel->setFont(font); + + m_uiForm.invsttableWidget->setSortingEnabled(true); + m_uiForm.invsttableWidget->sortByColumn(0,Qt::AscendingOrder); } /** Cancel button clicked */ @@ -335,42 +399,92 @@ void ICatInvestigation::onCancel() parent->close(); } } +void ICatInvestigation::onSelectAllFiles() +{ + QItemSelectionModel* selectionModel = m_uiForm.invsttableWidget->selectionModel(); + QAbstractItemModel *model = m_uiForm.invsttableWidget->model(); + int rowCount = model->rowCount(); + int colCount = model->columnCount(); + + QModelIndex topLeft = model->index(0,0,QModelIndex()); + QModelIndex bottomRight = model->index(rowCount-1,colCount-1,QModelIndex()); + + QItemSelection selection(topLeft, bottomRight); + selectionModel->select(selection, QItemSelectionModel::Select); + + +} +/// if data file checkbox selected +bool ICatInvestigation::isDataFilesChecked() +{ + return m_uiForm.dataFilescheckBox->isChecked(); +} /** This method gets the selected file name from the selected row in the table - *@param fileName - table widget item selected. + * @param fileNames - table widget item selected. */ -void ICatInvestigation::getSelctedFileName(QString& fileName ) +void ICatInvestigation::getSelectedFileNames(std::vector<std::string>& fileNames) { - QList<QTableWidgetItem *> items = m_uiForm.invsttableWidget->selectedItems(); - if(!items.empty()) - { - fileName=items[0]->text(); - } + QItemSelectionModel *selmodel = m_uiForm.invsttableWidget->selectionModel(); + QModelIndexList indexes=selmodel->selectedRows(); + QModelIndex index; + QAbstractItemModel *model = m_uiForm.invsttableWidget->model(); + foreach(index, indexes) + { + QString text = model->data(index, Qt::DisplayRole).toString(); + fileNames.push_back(text.toStdString()); + + } } /** download button clicked */ void ICatInvestigation::onDownload() { //get selected file name to download - QString fileName,fileLoc; + std::vector<std::string> fileNames; + std::vector<std::string> fileLocs; //get selected file from the Mantid-ICat interface to download - getSelctedFileName(fileName); - - if(executeDownloadDataFile(fileName,fileLoc)) + getSelectedFileNames(fileNames); + if(fileNames.empty()) + { + QString msg="No files are selected to download.Use 'Select All Files' button provided" + "\n or mouse left button and shift/Ctrl key to select the files."; + emit error(msg); + return; + } + if(executeDownloadDataFiles(fileNames,fileLocs)) { - //set archive file location. - setisisarchiveFileLocation(fileLoc); - //if download completed succesfully enable load button - m_uiForm.LoadButton->setEnabled(true); + //set file location. + setICatFileLocation(fileLocs); } + else + { + emit error("Downloading failed for data file "); + } + + //for(itr=fileNames.begin();itr!=fileNames.end();++itr) + //{ + // if(executeDownloadDataFile((*itr),fileLoc)) + // { + // //set file location. + // setICatFileLocation(fileLoc); + // emit error(fileLoc); + + // } + // else + // { + // emit error("Downloading failed for data file "+ fileName); + // } + //} } /**This method sets the isis archive location *@fileLoc - isis archive location */ -void ICatInvestigation::setisisarchiveFileLocation(const QString& fileLoc) +void ICatInvestigation::setICatFileLocation(const std::vector<std::string>& fileLocs) { - m_archiveLoc=fileLoc; + //m_downloadedFileListVec.push_back(fileLoc); + m_downloadedFileList.assign(fileLocs.begin(),fileLocs.end()); } /**This method gets called when Treewidget item defaults expanded @@ -411,69 +525,146 @@ void ICatInvestigation::investigationWidgetItemExpanded(QTreeWidgetItem* item ) /// Load button clicked void ICatInvestigation::onLoad() { - ///get filename (raw,nexus,log) from table widget to load to mantid - QString fileName; - getSelctedFileName(fileName); - QString wsName; - int index = fileName.lastIndexOf("."); - if(index!=-1) + ///get selected filename (raw,nexus,log) from table widget to load to mantid + + std::vector<std::string> sfileNames; + getSelectedFileNames(sfileNames); + if(sfileNames.empty()) { - wsName=fileName.left(index); + QString msg="Select the files to load using 'Select All files' button provided or " + "\n mouse left button and Shift/Ctrl Key and download the files using Download button."; + emit error( msg); } - QString filepath; - if(m_archiveLoc.isEmpty()) - { - filepath = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("icatDownload.directory")); - filepath += fileName; + + // for loop for checking the selected file names is there in the downloaded files list. + //users are suopposed to download first and then load + + std::vector<std::string>::const_iterator citr; + for(citr=sfileNames.begin();citr!=sfileNames.end();++citr) + { + //std::basic_string <char>::size_type npos = -1; + //std::basic_string <char>::size_type index; + //std::string filenamePart; + + //std::vector<std::string>::const_iterator cditr; + //for(cditr=m_downloadedFileList.begin();cditr!=m_downloadedFileList.end();++cditr) + //{ + // // the selected file name UI contains only file names,but the downloaded filelist returned + // // by downlaod algorithm contains filename with full path + // // so below code extarcts the file name part and checks file exists in the downloaded list + // index=(*cditr).find_last_of("/"); + // if(index!=npos) + // { + // filenamePart=(*cditr).substr(index+1,(*cditr).length()-index); + // //emit error("fileNamepart is "+QString::fromStdString(filenamePart) ); + // QString temp=QString::fromStdString(filenamePart); + // QString temp1=QString::fromStdString(*citr); + // if(!temp.compare(temp1,Qt::CaseInsensitive)) + // { + // //call load raw/nexus + // loadData(QString::fromStdString(*cditr)); + // } + // + // } + //} + std::string loadPath; + if(isFileExistsInDownlodedList(*citr,loadPath )) + { + loadData(QString::fromStdString(loadPath)); + } + else + { + emit error("The file "+ QString::fromStdString(*citr)+ " is not downloaded. Use the downlaod button provided to down load the file and then load." ); + } + } - else + + +} + +bool ICatInvestigation::isFileExistsInDownlodedList(const std::string& selectedFile,std::string& loadPath ) +{ + std::basic_string <char>::size_type npos = -1; + std::basic_string <char>::size_type index; + std::string filenamePart; + + std::vector<std::string>::const_iterator cditr; + for(cditr=m_downloadedFileList.begin();cditr!=m_downloadedFileList.end();++cditr) + { + // the selected file name UI contains only file names,but the downloaded filelist returned + // by downlaod algorithm contains filename with full path + // so below code extarcts the file name part and checks file exists in the downloaded list + index=(*cditr).find_last_of("/"); + if(index!=npos) + { + filenamePart=(*cditr).substr(index+1,(*cditr).length()-index); + //emit error("fileNamepart is "+QString::fromStdString(filenamePart) ); + QString temp=QString::fromStdString(filenamePart); + QString temp1=QString::fromStdString(selectedFile); + if(!temp.compare(temp1,Qt::CaseInsensitive)) + { + loadPath=(*cditr); + return true; + } + + } + + } + return false; + +} +/**This method loads the data file + *@param filePath name of the file + *@return boolean +*/ +bool ICatInvestigation::loadData( const QString& filePath) +{ + + QString wsName; + int index = filePath.lastIndexOf("."); + int index1 = filePath.lastIndexOf("/"); + if(index!=-1 && index1!=-1) { - filepath=m_archiveLoc; + wsName=filePath.mid(index1+1,index-index1); } - if (isRawFile(fileName)) + if (isRawFile(filePath)) { if(!isLoadingControlled()) { - if(!executeLoadRaw(filepath,wsName)) + if(!executeLoadRaw(filePath,wsName)) { - return; + return false; } } else { - emit loadRawAsynch(filepath,wsName); + emit loadRawAsynch(filePath,wsName); } } - else if (isNexusFile(fileName)) + else if (isNexusFile(filePath)) { - /*QString filepath; - if(m_archiveLoc.isEmpty()) - { - filepath = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("icatDownload.directory")); - filepath += fileName; - } - else - { - filepath=m_archiveLoc; - }*/ + if(!isLoadingControlled()) { - if(!executeLoadNexus(filepath,wsName)) + if(!executeLoadNexus(filePath,wsName)) { - return; + return false; } } else { - emit loadNexusAsynch(filepath,wsName); + emit loadNexusAsynch(filePath,wsName); + } } else { - emit error("ICat interface is not currently supporting the loading of files with extension .log"); + emit error("ICat interface is not currently supporting the loading of log files "); + return false; } + return true; } /// If user selected controlled loading of data check box bool ICatInvestigation::isLoadingControlled() @@ -487,6 +678,7 @@ bool ICatInvestigation::isLoadingControlled() */ bool ICatInvestigation::isRawFile(const QString& fileName) { + //return fileName.endsWith(".raw",Qt::CaseInsensitive); int index = fileName.lastIndexOf("."); bool braw; QString extn; @@ -511,9 +703,10 @@ bool ICatInvestigation::isNexusFile(const QString& fileName) { extn=fileName.right(fileName.length()-index-1); } - (!extn.compare("nxs")|| !extn.compare("NXS") )? bnxs=true : bnxs=false; + (!extn.compare("nxs",Qt::CaseInsensitive) )? bnxs=true : bnxs=false; return bnxs; + //return fileName.endsWith(".nxs",Qt::CaseInsensitive); } /** This method executes loadRaw algorithm @@ -521,7 +714,7 @@ bool ICatInvestigation::isNexusFile(const QString& fileName) */ bool ICatInvestigation::executeLoadRaw(const QString& fileName,const QString& wsName) { - return execute("LoadRaw",3,fileName,wsName); + return execute("LoadRaw",-1,fileName,wsName); } /** This method executes loadNexus algorithm @@ -529,7 +722,7 @@ bool ICatInvestigation::executeLoadRaw(const QString& fileName,const QString& ws */ bool ICatInvestigation::executeLoadNexus(const QString& fileName,const QString& wsName) { - return execute("LoadNexus",1,fileName,wsName); + return execute("LoadNexus",-1,fileName,wsName); } /**This method executes loadraw/loadnexus algorithm @@ -546,18 +739,11 @@ bool ICatInvestigation::execute(const QString& algName,const int& version,const } catch(...) { - throw std::runtime_error("Error when loading the raw file"+ fileName.toStdString()); + throw std::runtime_error("Error when loading the file"+ fileName.toStdString()); } try { alg->setProperty("Filename",fileName.toStdString()); - } - catch(std::invalid_argument&ex) - { - emit error(QString::fromStdString(ex.what())); - return false; - } - try{ alg->setPropertyValue("OutputWorkspace",wsName.toStdString()); } catch(std::invalid_argument& e) @@ -565,7 +751,21 @@ bool ICatInvestigation::execute(const QString& algName,const int& version,const emit error(e.what()); return false; } - alg->execute(); - return (alg->isExecuted()); + /*alg->execute(); + return (alg->isExecuted());*/ + try + { + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } + return (!result.failed()); + } + catch(...) + { + return false; + } + } diff --git a/Code/qtiplot/MantidQt/MantidWidgets/src/ICatMyDataSearch.cpp b/Code/qtiplot/MantidQt/MantidWidgets/src/ICatMyDataSearch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4f54f52879ba7121f8a9747fc3d716284fe0456d --- /dev/null +++ b/Code/qtiplot/MantidQt/MantidWidgets/src/ICatMyDataSearch.cpp @@ -0,0 +1,135 @@ +#include "MantidQtMantidWidgets/ICatMyDataSearch.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include<QStringList> +#include<QTreeWidget> +#include<QTreeWidgetItem> +#include<QFont> + +using namespace Mantid::API; +using namespace MantidQt::MantidWidgets; + +ICatMyDataSearch::ICatMyDataSearch(QWidget*par):QWidget(par) +{ + m_uiForm.setupUi(this); + + connect(this,SIGNAL(error(const QString&)),parent()->parent(),SLOT(writetoLogWindow(const QString& ))); + + Mantid::API::ITableWorkspace_sptr ws_sptr = executeMyDataSearch(); + if(!ws_sptr) + { + emit error("MyData search completed,No results to display."); + return; + } + + for (int i=m_uiForm.myDatatableWidget->rowCount()-1;i>=0;--i) + { + m_uiForm.myDatatableWidget->removeRow(i); + } + m_uiForm.myDatatableWidget->setRowCount(ws_sptr->rowCount()); + for (int i=0;i<ws_sptr->rowCount();++i) + { + //setting the row height of tableWidget + m_uiForm.myDatatableWidget->setRowHeight(i,20); + } + + QStringList qlabelList; + for(int i=0;i<ws_sptr->columnCount();i++) + { + Column_sptr col_sptr = ws_sptr->getColumn(i); + //get the column name to display as the header of table widget + qlabelList.push_back(QString::fromStdString(col_sptr->name())); + + for(int j=0;j<ws_sptr->rowCount();++j) + { + std::ostringstream ostr; + col_sptr->print(ostr,j); + QTableWidgetItem *newItem = new QTableWidgetItem(QString::fromStdString(ostr.str())); + newItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + m_uiForm.myDatatableWidget->setItem(j,i,newItem); + newItem->setToolTip(QString::fromStdString(ostr.str())); + // newItem->setBackground(QBrush(QColor(Qt::blue))); + } + m_uiForm.myDatatableWidget->resizeColumnToContents(i); + } + //setting table widget header labels from table workspace + m_uiForm.myDatatableWidget->setHorizontalHeaderLabels(qlabelList); + QFont font; + font.setBold(true); + for (int i=0;i<m_uiForm.myDatatableWidget->columnCount();++i) + { + m_uiForm.myDatatableWidget->horizontalHeaderItem(i)->setFont(font);; + } + //resizing the coluns based on data size + m_uiForm.myDatatableWidget->resizeColumnsToContents(); + + QString labelText; + std::stringstream totalCount; + totalCount<<ws_sptr->rowCount(); + labelText="Data: "+QString::fromStdString(totalCount.str())+" Investigations "+" found"; + + m_uiForm.mydatalabel->clear(); + m_uiForm.mydatalabel->setText(labelText); + m_uiForm.mydatalabel->setAlignment(Qt::AlignHCenter); + m_uiForm.mydatalabel->setFont(font); + + m_uiForm.myDatatableWidget->setSortingEnabled(true); + m_uiForm.myDatatableWidget->sortByColumn(2,Qt::AscendingOrder); + + +} +Mantid::API::ITableWorkspace_sptr ICatMyDataSearch::executeMyDataSearch() +{ + Mantid::API::IAlgorithm_sptr alg; + Mantid::API::ITableWorkspace_sptr ws_sptr; + try + { + alg = Mantid::API::AlgorithmManager::Instance().create("MyDataSearch",1); + } + catch(...) + { + throw std::runtime_error("Error when loading Mydata search results."); + } + try + { + alg->setPropertyValue("OutputWorkspace","MyInvestigations"); + } + catch(std::invalid_argument& e) + { + emit error(e.what()); + return ws_sptr; + } + + try + { + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } + //return (!result.failed()); + } + catch(...) + { + return ws_sptr; + } + if(AnalysisDataService::Instance().doesExist("MyInvestigations")) + { + ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> + (AnalysisDataService::Instance().retrieve("MyInvestigations")); + } + return ws_sptr; + +} + +//void MyTreeWidget::drawRow(QPainter* p, const QStyleOptionViewItem &opt, const QModelIndex &idx) const +//{ QTreeWidget::drawRow(p, opt, idx); +//for (int col = 0; col < columnCount(); ++col) +//{ QModelIndex s = idx.sibling(idx.row(), col); +//if (s.isValid()) +//{ +// QRect rect = visualRect(s); +// p->setPen(Qt::DotLine); +// p->drawRect(rect); } +//} +//} \ No newline at end of file diff --git a/Code/qtiplot/MantidQt/MantidWidgets/src/ICatSearch.cpp b/Code/qtiplot/MantidQt/MantidWidgets/src/ICatSearch.cpp index 685e15c0b5e8d2208b8d2dd5942af850bb1e2106..eb18350ebc9fc31c79c28a14e6e930bb7a779d59 100644 --- a/Code/qtiplot/MantidQt/MantidWidgets/src/ICatSearch.cpp +++ b/Code/qtiplot/MantidQt/MantidWidgets/src/ICatSearch.cpp @@ -12,14 +12,13 @@ #include<QTreeWidget> #include<QTreeWidgetItem> #include<QFont> -#include<QPainter> #include<QHeaderView> -#include<QPen> #include <QTableWidgetItem> #include <QSettings> -#include <QBrush> #include <QMdiSubWindow> + + using namespace Mantid::Kernel; using namespace Mantid::API; @@ -30,7 +29,8 @@ using namespace MantidQt::MantidWidgets; //---------------------- ///Constructor ICatSearch::ICatSearch(QWidget *par) : -QWidget(par) +QWidget(par),m_sender(NULL),m_invstWidget(NULL), +m_calendarWidget(NULL) { initLayout(); // getting the application window pointer and setting it @@ -41,7 +41,6 @@ QWidget(par) { setparentWidget(parent); } - } QWidget* ICatSearch::getParentWidget() { @@ -56,72 +55,70 @@ void ICatSearch::setparentWidget(QWidget* par) /// Set up the dialog layout void ICatSearch::initLayout() { - // - m_uiForm.setupUi(this); + m_uiForm.setupUi(this); - m_invstWidget=NULL; - - setToolTips(); //disable the table widget's vertical header m_uiForm.searchtableWidget->verticalHeader()->setVisible(false); populateInstrumentBox(); + //m_uiForm.calendarWidget->hide(); + + //getting last saved input data from registry readSettings(); connect(m_uiForm.searchButton,SIGNAL(clicked()),this,SLOT(onSearch())); - connect(m_uiForm.cancelButton,SIGNAL(clicked()),this,SLOT(onCancel())); - connect(m_uiForm.searchtableWidget,SIGNAL(itemDoubleClicked(QTableWidgetItem * )), + connect(m_uiForm.closeButton,SIGNAL(clicked()),this,SLOT(onClose())); + //connect(m_uiForm.okButton,SIGNAL(clicked()),this,SLOT(onOK())); + connect(m_uiForm.searchtableWidget,SIGNAL(itemDoubleClicked(QTableWidgetItem* )), this,SLOT(investigationSelected(QTableWidgetItem* ))); connect(this,SIGNAL(error(const QString&)),parent()->parent(),SLOT(writetoLogWindow(const QString& ))); + connect(m_uiForm.startdatetoolButton,SIGNAL(clicked()),this,SLOT(popupCalender())); + connect(m_uiForm.enddatetoolButton,SIGNAL(clicked()),this,SLOT(popupCalender())); + //connect(m_uiForm.calendarWidget,SIGNAL(clicked(const QDate&)) ,this,SLOT(getstartDate(const QDate&))); + } /// This method gets called when the widget is closed void ICatSearch::closeEvent(QCloseEvent*) { saveSettings(); } -/// This method sets the tool tips search input controls -void ICatSearch::setToolTips() -{ - m_uiForm.startRunEdit->setToolTip("The start run number for the range of investigations to be searched"); - m_uiForm.endRunEdit->setToolTip("The end run number for the range of investigations to be searched"); -} + /// This method is the handler for search button void ICatSearch::onSearch() { double startRun=0,endRun=0; //get start and end run values getRunValues(startRun,endRun); - - if(startRun==0 || endRun==0) - { - emit error("Run number cannot be zero.Enter valid strat and end run numbers to do Search."); - return; - } + //try to validate the UI level. if(startRun> endRun) { emit error("Run end number cannot be lower than run start number."); return; } - QString instrName; // get the selected instrument + QString instrName; getSelectedInstrument(instrName); - std::string instr(instrName.toStdString()); + QString startDate,endDate; + getDates(startDate,endDate); + // execute the search by run number algorithm ITableWorkspace_sptr ws_sptr = executeSearchByRunNumber(startRun,endRun,isCaseSensitiveSearch(),instr); - if(!ws_sptr) - { + if(!ws_sptr || ws_sptr->rowCount()==0) + { return; } updatesearchResults(ws_sptr); //setting the label string QFont font; font.setBold(true); - m_uiForm.searchlabel->setText("Investigations Search Results"); + std::stringstream rowcount; + rowcount<<ws_sptr->rowCount(); + m_uiForm.searchlabel->setText("Investigations Search Results : "+QString::fromStdString(rowcount.str()) + " Investigations Found"); m_uiForm.searchlabel->setAlignment(Qt::AlignHCenter); m_uiForm.searchlabel->setFont(font); } @@ -136,54 +133,13 @@ bool ICatSearch::isCaseSensitiveSearch() */ void ICatSearch::updatesearchResults(ITableWorkspace_sptr& ws_sptr ) { - - //int rows = ws_sptr->rowCount(); - //int columns = ws_sptr->columnCount(); - - //long long invstId=0; - //std::string stringValue; - //QStringList qlist; - - //QFont font; - //font.setBold(true); - - ////loop through table workspace rows - //for (int i=0;i<rows;++i) - //{ - // TableRow row =ws_sptr->getRow(i); - // row>>invstId; - // QString qinvstId=QString::number(invstId); - // m_uiForm.searchtableWidget->insertRow(i); - - // QTableWidgetItem *newItem = new QTableWidgetItem(qinvstId); - // m_uiForm.searchtableWidget->setItem(i, 0, newItem); - // newItem->setToolTip(qinvstId); - // - // // loop through columns - // for (int j=1;j<columns;++j) - // { - // row>>stringValue; - // QTableWidgetItem *newItem1 = new QTableWidgetItem(QString::fromStdString(stringValue)); - // //below if loop not working,look into it again later sometime. - // if(j==2) - // { - // QSize qsize; - // qsize.setWidth(400); - // newItem1->setSizeHint(qsize); - // } - // - // m_uiForm.searchtableWidget->setItem(i, j, newItem1); - // newItem1->setToolTip(QString::fromStdString(stringValue)); - // } - // - //} - ////setting the row height of tableWidget - //rows=m_uiForm.searchtableWidget->rowCount(); - //for (int i=0;i<rows;++i) - //{ - // m_uiForm.searchtableWidget->setRowHeight(i,20); - //} - // + if(!ws_sptr) + { + return ; + } + + //disable sorting as per QT documentation.otherwise setitem will give undesired results + m_uiForm.searchtableWidget->setSortingEnabled(false); //below for loop is for clearing the table widget on search button click.Bcoz Each click on search button to load data,rows were getting appended. // table widget clear() method is clearing only the tablewidgetitem text,not removing the rows,columns @@ -201,33 +157,34 @@ void ICatSearch::updatesearchResults(ITableWorkspace_sptr& ws_sptr ) m_uiForm.searchtableWidget->setRowHeight(i,20); } - QStringList qlabelList;//QBrush brush; - //QColor color("red"); + QStringList qlabelList; + //QBrush brush; + //QColor color(255,0,0); //brush.setColor(color); - for(int i=0;i<ws_sptr->columnCount();i++) + for(int i=0;i<ws_sptr->columnCount()-4;i++) { Column_sptr col_sptr = ws_sptr->getColumn(i); //get the column name to display as the header of table widget QString colTitle = QString::fromStdString(col_sptr->name()); qlabelList.push_back(colTitle); - + for(int j=0;j<ws_sptr->rowCount();++j) { std::ostringstream ostr; col_sptr->print(ostr,j); - + QTableWidgetItem *newItem = new QTableWidgetItem(QString::fromStdString(ostr.str())); newItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); m_uiForm.searchtableWidget->setItem(j,i, newItem); newItem->setToolTip(QString::fromStdString(ostr.str())); - //newItem->setBackground(brush); + // newItem->setBackground(QBrush(QColor(Qt::blue))); } } - //setting table widget header labels from table workspace - m_uiForm.searchtableWidget->setHorizontalHeaderLabels(qlabelList); QFont font; font.setBold(true); - for (int i=0;i<m_uiForm.searchtableWidget->columnCount();++i) + //setting table widget header labels from table workspace + m_uiForm.searchtableWidget->setHorizontalHeaderLabels(qlabelList); + for (int i=0;i<m_uiForm.searchtableWidget->columnCount()-4;++i) { m_uiForm.searchtableWidget->horizontalHeaderItem(i)->setFont(font);; } @@ -235,6 +192,9 @@ void ICatSearch::updatesearchResults(ITableWorkspace_sptr& ws_sptr ) m_uiForm.searchtableWidget->sortByColumn(2,Qt::AscendingOrder); // resizing the coulmn based on data size m_uiForm.searchtableWidget->resizeColumnsToContents (); + //enable sorting + m_uiForm.searchtableWidget->setSortingEnabled(true); + } /** This method populates the instrument box */ @@ -256,6 +216,7 @@ void ICatSearch::populateInstrumentBox(){ } //sorting the combo by instrument name; m_uiForm.instrmentBox->model()->sort(0); + m_uiForm.instrmentBox->insertItem(-1,""); } /** This method executes the ListInstruments algorithm * and fills the instrument box with instrument lists returned by ICat API @@ -284,16 +245,24 @@ ITableWorkspace_sptr ICatSearch::executeListInstruments() emit error(e.what()); return ws_sptr; } - alg->execute(); - - if(!alg->isExecuted()) + try { - return ws_sptr; + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } + //result.wait(); + } + catch(...) + { + return ws_sptr; + } + if(AnalysisDataService::Instance().doesExist("instruments")) + { + ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> + (AnalysisDataService::Instance().retrieve("instruments")); } - - ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> - (AnalysisDataService::Instance().retrieve("instruments")); - return ws_sptr; } /**This method gets run numbers from the start and end run boxes. @@ -305,6 +274,47 @@ void ICatSearch::getRunValues(double& startRun,double& endRun) endRun = m_uiForm.endRunEdit->text().toDouble(); startRun = m_uiForm.startRunEdit->text().toDouble(); } +/**This method gets start and end dates from the start and end date boxes. + *@param startDate - start date + *@param endDate - end date +*/ +void ICatSearch::getDates(QString& startDate,QString& endDate) +{ +//startDate = m_uiForm.startdateEdit->date().toString(); +//endDate = m_uiForm.enddateEdit->date().toString(); +} +///popup DateTime calender to select date +void ICatSearch:: popupCalender() +{ + //m_uiForm.calendarWidget->show(); + m_calendarWidget = new QCalendarWidget(this); + m_calendarWidget->setObjectName(QString::fromUtf8("calendarWidget")); + m_calendarWidget->setGeometry(QRect(386, 64, 211, 148)); + m_calendarWidget->setGridVisible(true); + connect(m_calendarWidget,SIGNAL(clicked(const QDate&)) ,this,SLOT(getstartDate(const QDate&))); + m_calendarWidget->show(); + + QObject * qsender= sender(); + if(!qsender) return; + m_sender=qsender; + +} +///date changed +void ICatSearch::getstartDate(const QDate& date ) +{ + //m_uiForm.calendarWidget->close(); + m_calendarWidget->close(); + if(!m_sender) return; + + if(!m_sender->objectName().compare("startdatetoolButton")) + { + m_uiForm.startdateLineEdit->setText(date.toString("dd/MM/yyyy")); + } + if(!m_sender->objectName().compare("enddatetoolButton")) + { + m_uiForm.enddateLineEdit->setText(date.toString("dd/MM/yyyy")); + } +} /**This method gets the selected instrument *@param instrName name of the selected instrument */ @@ -320,6 +330,19 @@ ITableWorkspace_sptr ICatSearch::executeSearchByRunNumber(const double &startRu { QString algName("SearchByRunNumber"); const int version=1; + + QString startDate = m_uiForm.startdateLineEdit->text(); + QString endDate =m_uiForm.enddateLineEdit->text(); + QString keywords= m_uiForm.keywordslineEdit->text(); + if(!startDate.compare("DD/MM/YYYY",Qt::CaseInsensitive)) + { + startDate=""; + } + if(!endDate.compare("DD/MM/YYYY",Qt::CaseInsensitive)) + { + endDate=""; + } + ITableWorkspace_sptr ws_sptr; Mantid::API::IAlgorithm_sptr alg; try @@ -335,7 +358,11 @@ ITableWorkspace_sptr ICatSearch::executeSearchByRunNumber(const double &startRu alg->setProperty("StartRun",startRun); alg->setProperty("EndRun",endRun); alg->setProperty("Instrument",instrName); + alg->setProperty("StartDate",startDate.toStdString()); + alg->setProperty("EndDate",endDate.toStdString()); + //alg->setProperty("Keywords",m_uiForm.enddateLineEdit->setText); alg->setProperty("Case Sensitive",bCase); + alg->setProperty("Keywords",keywords.toStdString()); alg->setProperty("OutputWorkspace","investigations"); } catch(std::invalid_argument& e) @@ -343,21 +370,42 @@ ITableWorkspace_sptr ICatSearch::executeSearchByRunNumber(const double &startRu emit error(e.what()); return ws_sptr; } - alg->execute(); - - if(!alg->isExecuted()) + try { - return ws_sptr; + Poco::ActiveResult<bool> result(alg->executeAsync()); + while( !result.available() ) + { + QCoreApplication::processEvents(); + } + //result.wait(); + } + catch(...) + { + return ws_sptr; + } + if(AnalysisDataService::Instance().doesExist("investigations")) + { + ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> + (AnalysisDataService::Instance().retrieve("investigations")); } - - ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace> - (AnalysisDataService::Instance().retrieve("investigations")); return ws_sptr; } /** This method cancels the search widget. */ -void ICatSearch::onCancel() +void ICatSearch::onClose() +{ + this->close(); + QObject* qobj=parent(); + QWidget* parent=qobject_cast<QWidget*>(qobj); + if(parent) + { + parent->close(); + } +} +/** This method cancels the search widget. +*/ +void ICatSearch::onOK() { this->close(); QObject* qobj=parent(); @@ -372,6 +420,7 @@ void ICatSearch::onCancel() */ void ICatSearch::investigationSelected(QTableWidgetItem * item ) { + if(!item) return ; int row=item->row(); // column zero is investigation id @@ -381,17 +430,22 @@ void ICatSearch::investigationSelected(QTableWidgetItem * item ) //column one is RbNumber QTableWidgetItem* rbNumberItem = m_uiForm.searchtableWidget->item(row,1); + if(!rbNumberItem) return; QString qRbNumber = rbNumberItem->text(); ///column two is Title QTableWidgetItem* titleItem = m_uiForm.searchtableWidget->item(row,2); + if(!titleItem)return ; QString qTitle = titleItem->text(); //column 4 is Instrument QTableWidgetItem* instrumentItem = m_uiForm.searchtableWidget->item(row,3); + if(!instrumentItem)return; QString qInstrument = instrumentItem->text(); //parent of user_win is application window; QMdiSubWindow* usr_win = new QMdiSubWindow(m_applicationWindow); + if(!usr_win) return; usr_win->setAttribute(Qt::WA_DeleteOnClose, false); + m_invstWidget= new MantidQt::MantidWidgets::ICatInvestigation(invstId,qRbNumber,qTitle,qInstrument,usr_win); if( m_invstWidget ) { @@ -404,10 +458,6 @@ void ICatSearch::investigationSelected(QTableWidgetItem * item ) usr_win->move(QPoint(600, 400)); usr_win->show(); } - //// create investigation widget - //m_invstWidget= new MantidQt::MantidWidgets::ICatInvestigation(invstId,qRbNumber,qTitle,qInstrument,NULL); - //m_invstWidget->show(); - } /** This method saves search settings diff --git a/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp b/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp index 20d90fc342f1bc33411566c88795bb637290e621..577372ac323c26defe9a18bb1f74c6c5efc0e99e 100644 --- a/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp +++ b/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp @@ -179,6 +179,7 @@ #include "MantidQtAPI/UserSubWindow.h" #include "MantidQtAPI/AlgorithmInputHistory.h" #include "MantidQtMantidWidgets/ICatSearch.h" +#include "MantidQtMantidWidgets/ICatMyDataSearch.h" using namespace Qwt3D; @@ -1159,6 +1160,7 @@ void ApplicationWindow::initMainMenu() icat->setObjectName("ICatMenu"); icat->addAction(actionICatLogin); icat->addAction(actionICatSearch); + icat->addAction(actionMydataSearch); icat->addAction(actionICatLogout); disableActions(); } @@ -12555,8 +12557,12 @@ void ApplicationWindow::createActions() //actionLogon->setShortcut(QKeySequence::fromString("Ctrl+Shift+L")); actionICatSearch->setToolTip(tr("ICat Search")); connect(actionICatSearch, SIGNAL(activated()), this, SLOT(ICatSearch())); - //connect(actionICatSearch, SIGNAL(triggered(QAction*)), this, SLOT(performCustomAction(QAction*))); + actionMydataSearch=new QAction("MyData Search",this); + //actionLogon->setShortcut(QKeySequence::fromString("Ctrl+Shift+L")); + actionMydataSearch->setToolTip(tr("ICat Search")); + connect(actionMydataSearch, SIGNAL(activated()), this, SLOT(ICatMyDataSearch())); + actionICatLogout=new QAction("Logout",this); //actionLogon->setShortcut(QKeySequence::fromString("Ctrl+Shift+L")); actionICatLogout->setToolTip(tr("ICat Logout")); @@ -16452,13 +16458,28 @@ void ApplicationWindow::ICatSearch() delete usr_win; } } +void ApplicationWindow::ICatMyDataSearch() +{ + QMdiSubWindow* usr_win = new QMdiSubWindow(this); + usr_win->setAttribute(Qt::WA_DeleteOnClose, false); + //QWidget* icatsearch_interface = new MantidQt::MantidWidgets::ICatSearch1(usr_win); + QWidget* icatsearch_interface = new MantidQt::MantidWidgets::ICatMyDataSearch(usr_win); + if(icatsearch_interface) + { + setGeometry(usr_win,icatsearch_interface); + } + else + { + delete usr_win; + } +} void ApplicationWindow::setGeometry(QMdiSubWindow* usr_win,QWidget* user_interface) { QRect frame = QRect(usr_win->frameGeometry().topLeft() - usr_win->geometry().topLeft(), usr_win->geometry().bottomRight() - usr_win->geometry().bottomRight()); usr_win->setWidget(user_interface); QRect iface_geom = QRect(frame.topLeft() + user_interface->geometry().topLeft(), - frame.bottomRight() + user_interface->geometry().bottomRight()+QPoint(15,35)); + frame.bottomRight() + user_interface->geometry().bottomRight()); usr_win->setGeometry(iface_geom); d_workspace->addSubWindow(usr_win); usr_win->show(); @@ -16468,7 +16489,7 @@ void ApplicationWindow::setGeometry(QMdiSubWindow* usr_win,QWidget* user_interfa } void ApplicationWindow::ICatLogout() { - mantidUI->executeICatLogout(1); + mantidUI->executeICatLogout(-1); } ///slot for writing to log window diff --git a/Code/qtiplot/qtiplot/src/ApplicationWindow.h b/Code/qtiplot/qtiplot/src/ApplicationWindow.h index 60f1486a624da5d39f6b623009f3e4335633a472..08b29de16bce252a0c827e2c490e6d499725d6d9 100644 --- a/Code/qtiplot/qtiplot/src/ApplicationWindow.h +++ b/Code/qtiplot/qtiplot/src/ApplicationWindow.h @@ -1081,6 +1081,8 @@ private slots: void ICatLogin(); /// Handler for ICat search menu void ICatSearch(); + /// Handler for ICatMyData serch menu + void ICatMyDataSearch(); void ICatLogout(); @@ -1278,7 +1280,7 @@ private: QAction *actionCopyWindow, *actionShowAllColumns, *actionHideSelectedColumns; QAction *actionCutSelection, *actionCopySelection, *actionPasteSelection, *actionClearSelection; QAction *actionShowExplorer, *actionShowLog, *actionAddLayer, *actionShowLayerDialog, *actionAutomaticLayout,*actionclearAllMemory; - QAction *actionICatLogin,*actionICatSearch,*actionICatLogout; + QAction *actionICatLogin,*actionICatSearch,*actionMydataSearch,*actionICatLogout; #ifdef SCRIPTING_CONSOLE QAction *actionShowConsole; #endif