18 #include "milxQtManager.h" 22 setTabsClosable(
true);
23 setObjectName(
"Manager");
31 milxQtManager::~milxQtManager()
38 QTreeWidget *treeWidget =
new QTreeWidget(
this);
40 treeWidget->setColumnCount(headings.size());
41 treeWidget->setHeaderLabels(headings);
43 int newIndex = addTab(treeWidget, tabTitle);
44 setCurrentIndex(newIndex);
52 if(count() > 1 || index > 0)
56 if(index > 0 && currentIndex() == index)
57 newIndex = currentIndex();
60 setCurrentIndex(newIndex);
66 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>( currentWidget() );
76 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>( widget(tabIndex) );
86 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>( currentWidget() );
91 QPointer<QFileDialog> fileOpener =
new QFileDialog;
92 QSettings settings(
"Shekhar Chandra",
"milxQt");
93 QString path = settings.value(
"recentPath").toString();
95 if(filename.isEmpty())
97 QFileDialog *fileOpener =
new QFileDialog;
98 filename = fileOpener->getSaveFileName(
this,
99 tr(
"Select File to Save"),
101 tr(openOtherExts.c_str()) );
104 if(filename.isEmpty())
108 txtFile.setFileName(filename);
109 if(!txtFile.open(QIODevice::WriteOnly | QIODevice::Text))
115 QTextStream outFile(&txtFile);
116 QTreeWidgetItemIterator itemIterator(currentTree);
117 while (*itemIterator)
119 QTreeWidgetItem *item = *itemIterator;
120 for(
int j = 0; j < item->columnCount(); j ++)
122 outFile << item->text(j);
123 if(j < item->columnCount()-1)
134 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>( currentWidget() );
135 QTreeWidgetItem *newEntry =
new QTreeWidgetItem(currentTree);
137 for(
int j = 0; j < entries.size(); j ++)
138 newEntry->setText(j, entries[j]);
139 newEntry->setFlags(flags);
140 currentTree->itemBelow(newEntry);
145 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>( widget(tabIndex) );
146 QTreeWidgetItem *newEntry =
new QTreeWidgetItem(currentTree);
148 for(
int j = 0; j < entries.size(); j ++)
149 newEntry->setText(j, entries[j]);
150 newEntry->setFlags(flags);
152 currentTree->itemBelow(newEntry);
157 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>( widget(tabIndex) );
158 QTreeWidgetItem *newEntry =
new QTreeWidgetItem(currentTree);
160 for(
int j = 0; j < entries.size(); j ++)
161 newEntry->setText(j, entries[j]);
163 currentTree->setItemWidget(newEntry, widgetColumn, itemWidgetToAdd);
164 currentTree->itemBelow(newEntry);
169 QTreeWidget *currentTree = qobject_cast<QTreeWidget *>(widget(tabIndex));
173 QTreeWidgetItem *topLevelEntry =
new QTreeWidgetItem(currentTree, topLevelName);
174 currentTree->addTopLevelItem(topLevelEntry);
177 for (
int j = 0; j < entryList.size(); j++)
179 QTreeWidgetItem *newEntry =
new QTreeWidgetItem(topLevelEntry, entryList[j]);
180 newEntry->setFlags(flags);
182 currentTree->itemBelow(newEntry);
191 actionExportTab->setText(QApplication::translate(
"Manager",
"Export Contents ...", 0, QApplication::UnicodeUTF8));
194 actionClearTab->setText(QApplication::translate(
"Manager",
"Clear Tab", 0, QApplication::UnicodeUTF8));
197 actionClear->setText(QApplication::translate(
"Manager",
"Clear Manager", 0, QApplication::UnicodeUTF8));
203 connect(
this, SIGNAL(tabCloseRequested(
int)),
this, SLOT(
closeTab(
int)));
207 connect(
actionClear, SIGNAL(triggered()),
this, SLOT(clear()));
212 QMenu* contextMenu =
new QMenu(
this);
218 contextMenu->exec(currentEvent->globalPos());
QAction * actionClearTab
clear tab action
QAction * actionExportTab
export tab action
void PrintError(const std::string msg)
Displays a generic msg to standard error with carriage return.
void closeTab(int index)
Close the current tab.
int newTab(QString tabTitle, QStringList headings)
Creates a new tab in the manager with the title and headings provided.
QAction * actionClear
clear manager action
void addItem(QStringList entries, Qt::ItemFlags flags=Qt::ItemIsEnabled|Qt::ItemIsSelectable)
Add all the entries in list to the view.
void addTreeItem(int tabIndex, QStringList topLevelName, QList< QStringList > entryList, Qt::ItemFlags flags=Qt::ItemIsEnabled|Qt::ItemIsSelectable)
Add all the entries in list to the view like a tree.
void exportTab(QString filename="")
Clear the tab given by index.
void createConnections()
Create the connections for context menu etc.
void contextMenuEvent(QContextMenuEvent *event)
The context menu setup member.
milxQtManager(QWidget *theParent=0)
The standard constructor.
void createActions()
Create the actions for context menu etc.
void clearTab()
Clear the current tab.