1 /***************************************************************************
2 * Copyright (C) 2005 by David Cuadrado *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #include <QHeaderView>
25 #include <dgui/iconloader.h>
27 #include <yamf/model/library.h>
28 #include <yamf/model/libraryobject.h>
31 GCTable::GCTable(QWidget
*parent
)
32 : QTreeWidget(parent
), m_currentFolder(0)
34 setHeaderLabels(QStringList() << "" << "" );
36 header()->setResizeMode(QHeaderView::ResizeToContents
);
44 void GCTable::createFolder(const QString
&name
)
46 QTreeWidgetItem
*newFolder
= new QTreeWidgetItem(this);
50 newFolder
->setText(0, tr("New folder %1").arg( topLevelItemCount ()) );
54 newFolder
->setText(0, name
);
57 newFolder
->setIcon(0, DGui::IconLoader::self()->load( "folder.svg" ));
58 m_currentFolder
= newFolder
;
60 setCurrentItem(m_currentFolder
);
65 QTreeWidgetItem
*GCTable::currentFolder()
67 return m_currentFolder
;
70 void GCTable::setCurrentFolder(QTreeWidgetItem
*cf
)
78 void GCTable::removeCurrentFolder()
80 if ( m_currentFolder
)
82 int index
= indexOfTopLevelItem(m_currentFolder
) - 1;
84 delete m_currentFolder
;
86 m_currentFolder
= topLevelItem (index
);
87 setCurrentItem(m_currentFolder
);
91 void GCTable::commitData( QWidget
* editor
)
93 QLineEdit
*lineEdit
= qobject_cast
<QLineEdit
*>(editor
);
95 QTreeWidgetItem
*item
= currentItem ();
98 symbol
= item
->text(0);
99 // QTreeWidget::commitData(0); // Don't rename
103 emit
requestRenameSymbol(symbol
, lineEdit
->text());
106 QTreeWidget::commitData(editor
);