QvisFilePanelItem.C 7.11 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2014, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-442911
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9 10 11 12 13 14 15 16 17 18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
19 20 21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22 23 24 25 26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
27 28 29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30 31 32 33 34 35 36 37 38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

whitlocb's avatar
whitlocb committed
39
#include <QvisFilePanelItem.h>
hrchilds's avatar
hrchilds committed
40 41 42
#include <QualifiedFilename.h>

// Some static constants.
whitlocb's avatar
whitlocb committed
43 44 45 46
const int QvisFilePanelItem::ROOT_NODE = 0;
const int QvisFilePanelItem::HOST_NODE = 1;
const int QvisFilePanelItem::DIRECTORY_NODE = 2;
const int QvisFilePanelItem::FILE_NODE = 3;
hrchilds's avatar
hrchilds committed
47 48

// Static member variables.
whitlocb's avatar
whitlocb committed
49
int QvisFilePanelItem::globalNodeNumber = 0;
hrchilds's avatar
hrchilds committed
50 51

// *******************************************************************
whitlocb's avatar
whitlocb committed
52
// Method: QvisFilePanelItem::QvisFilePanelItem
hrchilds's avatar
hrchilds committed
53 54
//
// Purpose: 
whitlocb's avatar
whitlocb committed
55
//   A constructor for the QvisFilePanelItem class.
hrchilds's avatar
hrchilds committed
56 57
//
// Arguments:
whitlocb's avatar
whitlocb committed
58
//   parent : The tree widget to which this item will be added as a 
hrchilds's avatar
hrchilds committed
59 60 61 62 63 64 65 66
//            top level element.
//   str    : The text to display in the item.
//   qf     : The qualified filename associated with the item. This is
//            empty if the item is a host.
//   node   : The node type of the file list item. root,host,file,directory.
//   state  : The file's time state. It's > 0 if the file is a multi-
//            cycle database.
//
whitlocb's avatar
whitlocb committed
67 68 69 70
// Programmer: Cyrus Harrison
// Creation:   Tue Jul  1 14:05:53 PDT 2008
//
// Notes: Qt4 port - adapated from Brad Whitlock's QvisListViewFileItem class.
hrchilds's avatar
hrchilds committed
71 72 73 74 75
//
// Modifications:
//
// *******************************************************************

whitlocb's avatar
whitlocb committed
76 77 78 79
QvisFilePanelItem::QvisFilePanelItem(QTreeWidget *parent,
    const QString &str, const QualifiedFilename &qf, 
    int node, int state,bool tsForced) 
: QTreeWidgetItem(parent), file(qf)
hrchilds's avatar
hrchilds committed
80
{
whitlocb's avatar
whitlocb committed
81
    setText(0,str);
hrchilds's avatar
hrchilds committed
82
    nodeType = node;
whitlocb's avatar
whitlocb committed
83
    timeState = state;
hrchilds's avatar
hrchilds committed
84
    nodeNumber = globalNodeNumber++;
85
    timeStateHasBeenForced = tsForced;
hrchilds's avatar
hrchilds committed
86 87 88
}

// *******************************************************************
whitlocb's avatar
whitlocb committed
89
// Method: QvisFilePanelItem::QvisFilePanelItem
hrchilds's avatar
hrchilds committed
90 91
//
// Purpose: 
whitlocb's avatar
whitlocb committed
92
//   A constructor for the QvisFilePanelItem class.
hrchilds's avatar
hrchilds committed
93 94
//
// Arguments:
whitlocb's avatar
whitlocb committed
95
//   parent : The tree widget item to which this item will be added as a 
hrchilds's avatar
hrchilds committed
96 97 98 99 100 101 102 103
//            child element.
//   str    : The text to display in the item.
//   qf     : The qualified filename associated with the item. This is
//            empty if the item is a host.
//   node   : The node type of the file list item. root,host,file,directory.
//   state  : The file's time state. It's > 0 if the file is a multi-
//            cycle database.
//
whitlocb's avatar
whitlocb committed
104 105 106 107
// Programmer: Cyrus Harrison
// Creation:   Tue Jul  1 14:05:53 PDT 2008
//
// Notes: Qt4 port - adapated from Brad Whitlock's QvisListViewFileItem class.
hrchilds's avatar
hrchilds committed
108 109
//
// Modifications:
whitlocb's avatar
whitlocb committed
110
//
hrchilds's avatar
hrchilds committed
111 112
// *******************************************************************

whitlocb's avatar
whitlocb committed
113 114 115 116
QvisFilePanelItem::QvisFilePanelItem(QTreeWidgetItem *parent,
    const QString &str, const QualifiedFilename &qf, 
    int node, int state, bool tsForced) 
: QTreeWidgetItem(parent), file(qf)
hrchilds's avatar
hrchilds committed
117
{
whitlocb's avatar
whitlocb committed
118
    setText(0,str);
hrchilds's avatar
hrchilds committed
119
    nodeType = node;
whitlocb's avatar
whitlocb committed
120
    timeState = state;
hrchilds's avatar
hrchilds committed
121
    nodeNumber = globalNodeNumber++;
122
    timeStateHasBeenForced = tsForced;
hrchilds's avatar
hrchilds committed
123 124 125
}

// *******************************************************************
whitlocb's avatar
whitlocb committed
126
// Method: QvisFilePanelItem::~QvisFilePanelItem
hrchilds's avatar
hrchilds committed
127 128
//
// Purpose: 
whitlocb's avatar
whitlocb committed
129
//   Destructor for the QvisFilePanelItem class.
hrchilds's avatar
hrchilds committed
130
//
whitlocb's avatar
whitlocb committed
131 132
// Programmer: Cyrus Harrison
// Creation:   Tue Jul  1 14:05:53 PDT 2008
hrchilds's avatar
hrchilds committed
133 134 135 136 137
//
// Modifications:
//   
// *******************************************************************

whitlocb's avatar
whitlocb committed
138 139
QvisFilePanelItem::~QvisFilePanelItem()
{}
hrchilds's avatar
hrchilds committed
140

whitlocb's avatar
whitlocb committed
141
/*
hrchilds's avatar
hrchilds committed
142
// ****************************************************************************
whitlocb's avatar
whitlocb committed
143
// Method: QvisFilePanelItem::paintCell
hrchilds's avatar
hrchilds committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
//
// Purpose: 
//   Paints the cell.
//
// Note:       Files that can't be read are grayed out.
//
// Programmer: Brad Whitlock
// Creation:   Wed May 14 15:07:48 PST 2003
//
// Modifications:
//   
// ****************************************************************************

void
QvisListViewFileItem::paintCell(QPainter *p, const QColorGroup &cg,
    int column, int width, int align)
{
    if(file.CanAccess())
whitlocb's avatar
whitlocb committed
162
        QTreeViewItem::paintCell(p, cg, column, width, align);
hrchilds's avatar
hrchilds committed
163 164 165 166 167
    else
    {
        QColorGroup newCg(cg);
        newCg.setColor(QColorGroup::Text, Qt::gray);
        newCg.setColor(QColorGroup::HighlightedText, Qt::gray);
whitlocb's avatar
whitlocb committed
168
        QTreeViewItem::paintCell(p, newCg, column, width, align);
hrchilds's avatar
hrchilds committed
169 170 171 172
    }
}

// ****************************************************************************
whitlocb's avatar
whitlocb committed
173
// Method: QvisFilePanelItem::key
hrchilds's avatar
hrchilds committed
174 175
//
// Purpose: 
whitlocb's avatar
whitlocb committed
176 177
//   This method returns the key used by the QTreeView container for sorting
//   the items in the QTreeView.
hrchilds's avatar
hrchilds committed
178 179 180 181 182 183 184 185 186
//
// Programmer: Brad Whitlock
// Creation:   Thu Mar 22 17:10:53 PST 2001
//
// Modifications:
//   
// ****************************************************************************

QString
whitlocb's avatar
whitlocb committed
187
QvisFilePanelItem::key(int, bool) const
hrchilds's avatar
hrchilds committed
188 189 190 191 192 193
{
    QString temp;
    temp.sprintf("%08d", nodeNumber);
    return temp;
}

whitlocb's avatar
whitlocb committed
194 195
*/

hrchilds's avatar
hrchilds committed
196
// ****************************************************************************
whitlocb's avatar
whitlocb committed
197
// Method: QvisFilePanelItem::resetNodeNumber
hrchilds's avatar
hrchilds committed
198 199 200 201 202 203 204 205 206 207 208 209 210
//
// Purpose: 
//   This is a static method that resets the number sequence used in the keys
//   to zero.
//
// Programmer: Brad Whitlock
// Creation:   Thu Mar 22 17:11:45 PST 2001
//
// Modifications:
//   
// ****************************************************************************

void
whitlocb's avatar
whitlocb committed
211
QvisFilePanelItem::resetNodeNumber()
hrchilds's avatar
hrchilds committed
212 213 214
{
    globalNodeNumber = 0;
}