mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Use new RDTreeWidget everywhere in favour of QTreeWidget
* Since we're promoting everything, we reset the behaviour of RDTreeWidget so that it's not doing anything different by default. * RDTreeWidget's interface is a bit different, exposing some useful things like a single selected item and so on. * We also can't set columns in the Qt Creator UI anymore, so we set them from code.
This commit is contained in:
@@ -41,7 +41,7 @@ struct RemoteConnect
|
||||
|
||||
Q_DECLARE_METATYPE(RemoteConnect);
|
||||
|
||||
static void setRemoteConnect(QTreeWidgetItem *item, const RemoteConnect &connect)
|
||||
static void setRemoteConnect(RDTreeWidgetItem *item, const RemoteConnect &connect)
|
||||
{
|
||||
if(!item)
|
||||
return;
|
||||
@@ -49,7 +49,7 @@ static void setRemoteConnect(QTreeWidgetItem *item, const RemoteConnect &connect
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(connect));
|
||||
}
|
||||
|
||||
static RemoteConnect getRemoteConnect(QTreeWidgetItem *item)
|
||||
static RemoteConnect getRemoteConnect(RDTreeWidgetItem *item)
|
||||
{
|
||||
if(!item)
|
||||
return RemoteConnect();
|
||||
@@ -57,7 +57,7 @@ static RemoteConnect getRemoteConnect(QTreeWidgetItem *item)
|
||||
return item->data(0, Qt::UserRole).value<RemoteConnect>();
|
||||
}
|
||||
|
||||
static void setRemoteHost(QTreeWidgetItem *item, RemoteHost *host)
|
||||
static void setRemoteHost(RDTreeWidgetItem *item, RemoteHost *host)
|
||||
{
|
||||
if(!item)
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ static void setRemoteHost(QTreeWidgetItem *item, RemoteHost *host)
|
||||
item->setData(0, Qt::UserRole + 1, QVariant::fromValue((uintptr_t)host));
|
||||
}
|
||||
|
||||
static RemoteHost *getRemoteHost(QTreeWidgetItem *item)
|
||||
static RemoteHost *getRemoteHost(RDTreeWidgetItem *item)
|
||||
{
|
||||
if(!item)
|
||||
return NULL;
|
||||
@@ -73,14 +73,6 @@ static RemoteHost *getRemoteHost(QTreeWidgetItem *item)
|
||||
return (RemoteHost *)item->data(0, Qt::UserRole + 1).value<uintptr_t>();
|
||||
}
|
||||
|
||||
static void setItalic(QTreeWidgetItem *node, bool italic)
|
||||
{
|
||||
QFont f = node->font(0);
|
||||
f.setItalic(italic);
|
||||
node->setFont(0, f);
|
||||
node->setFont(1, f);
|
||||
}
|
||||
|
||||
RemoteManager::RemoteManager(ICaptureContext &ctx, MainWindow *main)
|
||||
: QDialog(NULL), ui(new Ui::RemoteManager), m_Ctx(ctx), m_Main(main)
|
||||
{
|
||||
@@ -88,7 +80,7 @@ RemoteManager::RemoteManager(ICaptureContext &ctx, MainWindow *main)
|
||||
|
||||
m_ExternalRef.release(1);
|
||||
|
||||
ui->hosts->setClearSelectionOnFocusLoss(false);
|
||||
ui->hosts->setColumns({tr("Hostname"), tr("Running")});
|
||||
|
||||
ui->hosts->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->hosts->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
@@ -130,7 +122,7 @@ void RemoteManager::closeWhenFinished()
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
void RemoteManager::setRemoteServerLive(QTreeWidgetItem *node, bool live, bool busy)
|
||||
void RemoteManager::setRemoteServerLive(RDTreeWidgetItem *node, bool live, bool busy)
|
||||
{
|
||||
RemoteHost *host = getRemoteHost(node);
|
||||
|
||||
@@ -163,7 +155,7 @@ void RemoteManager::setRemoteServerLive(QTreeWidgetItem *node, bool live, bool b
|
||||
}
|
||||
}
|
||||
|
||||
bool RemoteManager::isRemoteServerLive(QTreeWidgetItem *node)
|
||||
bool RemoteManager::isRemoteServerLive(RDTreeWidgetItem *node)
|
||||
{
|
||||
RemoteHost *host = getRemoteHost(node);
|
||||
return host && host->ServerRunning;
|
||||
@@ -171,15 +163,14 @@ bool RemoteManager::isRemoteServerLive(QTreeWidgetItem *node)
|
||||
|
||||
void RemoteManager::addHost(RemoteHost *host)
|
||||
{
|
||||
QTreeWidgetItem *node = makeTreeNode({host->Hostname, "..."});
|
||||
RDTreeWidgetItem *node = new RDTreeWidgetItem({host->Hostname, "..."});
|
||||
|
||||
setItalic(node, true);
|
||||
node->setItalic(true);
|
||||
node->setIcon(0, Icons::hourglass());
|
||||
setRemoteHost(node, host);
|
||||
|
||||
ui->hosts->addTopLevelItem(node);
|
||||
ui->hosts->clearSelection();
|
||||
node->setSelected(true);
|
||||
ui->hosts->setSelectedItem(node);
|
||||
|
||||
ui->refreshOne->setEnabled(false);
|
||||
ui->refreshAll->setEnabled(false);
|
||||
@@ -197,7 +188,7 @@ void RemoteManager::updateLookupsStatus()
|
||||
ui->progressCount->setText(tr("%1 lookups remaining").arg(m_Lookups.available()));
|
||||
}
|
||||
|
||||
void RemoteManager::runRemoteServer(QTreeWidgetItem *node)
|
||||
void RemoteManager::runRemoteServer(RDTreeWidgetItem *node)
|
||||
{
|
||||
RemoteHost *host = getRemoteHost(node);
|
||||
|
||||
@@ -210,7 +201,7 @@ void RemoteManager::runRemoteServer(QTreeWidgetItem *node)
|
||||
refreshHost(node);
|
||||
}
|
||||
|
||||
void RemoteManager::refreshHost(QTreeWidgetItem *node)
|
||||
void RemoteManager::refreshHost(RDTreeWidgetItem *node)
|
||||
{
|
||||
RemoteHost *host = getRemoteHost(node);
|
||||
|
||||
@@ -262,7 +253,7 @@ void RemoteManager::refreshHost(QTreeWidgetItem *node)
|
||||
RemoteConnect tag(hostname, nextIdent);
|
||||
|
||||
GUIInvoke::call([this, node, target, running, tag]() {
|
||||
QTreeWidgetItem *child = makeTreeNode({target, running});
|
||||
RDTreeWidgetItem *child = new RDTreeWidgetItem({target, running});
|
||||
setRemoteConnect(child, tag);
|
||||
node->addChild(child);
|
||||
ui->hosts->expandItem(node);
|
||||
@@ -272,7 +263,7 @@ void RemoteManager::refreshHost(QTreeWidgetItem *node)
|
||||
}
|
||||
}
|
||||
|
||||
GUIInvoke::call([node]() { setItalic(node, false); });
|
||||
GUIInvoke::call([node]() { node->setItalic(false); });
|
||||
|
||||
m_Lookups.acquire();
|
||||
|
||||
@@ -303,7 +294,7 @@ void RemoteManager::updateStatus()
|
||||
updateLookupsStatus();
|
||||
}
|
||||
|
||||
void RemoteManager::connectToApp(QTreeWidgetItem *node)
|
||||
void RemoteManager::connectToApp(RDTreeWidgetItem *node)
|
||||
{
|
||||
if(node)
|
||||
{
|
||||
@@ -320,10 +311,10 @@ void RemoteManager::connectToApp(QTreeWidgetItem *node)
|
||||
|
||||
void RemoteManager::updateConnectButton()
|
||||
{
|
||||
if(!ui->hosts->selectedItems().isEmpty())
|
||||
{
|
||||
QTreeWidgetItem *item = ui->hosts->selectedItems()[0];
|
||||
RDTreeWidgetItem *item = ui->hosts->selectedItem();
|
||||
|
||||
if(item)
|
||||
{
|
||||
ui->connect->setEnabled(true);
|
||||
ui->connect->setText(tr("Connect to App"));
|
||||
|
||||
@@ -391,10 +382,12 @@ void RemoteManager::addNewHost()
|
||||
|
||||
void RemoteManager::setRunCommand()
|
||||
{
|
||||
if(ui->hosts->selectedItems().isEmpty())
|
||||
RDTreeWidgetItem *item = ui->hosts->selectedItem();
|
||||
|
||||
if(!item)
|
||||
return;
|
||||
|
||||
RemoteHost *h = getRemoteHost(ui->hosts->selectedItems()[0]);
|
||||
RemoteHost *h = getRemoteHost(item);
|
||||
|
||||
if(h)
|
||||
{
|
||||
@@ -403,14 +396,14 @@ void RemoteManager::setRunCommand()
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteManager::on_hosts_itemActivated(QTreeWidgetItem *item, int column)
|
||||
void RemoteManager::on_hosts_itemActivated(RDTreeWidgetItem *item, int column)
|
||||
{
|
||||
RemoteConnect connect = getRemoteConnect(item);
|
||||
if(connect.ident > 0)
|
||||
connectToApp(item);
|
||||
}
|
||||
|
||||
void RemoteManager::on_hosts_itemClicked(QTreeWidgetItem *item, int column)
|
||||
void RemoteManager::on_hosts_itemClicked(RDTreeWidgetItem *item, int column)
|
||||
{
|
||||
ui->addUpdateHost->setText(tr("Add"));
|
||||
ui->addUpdateHost->setEnabled(true);
|
||||
@@ -458,11 +451,11 @@ void RemoteManager::on_hostname_textEdited(const QString &text)
|
||||
ui->addUpdateHost->setEnabled(true);
|
||||
ui->runCommand->setEnabled(true);
|
||||
|
||||
QTreeWidgetItem *node = NULL;
|
||||
RDTreeWidgetItem *node = NULL;
|
||||
|
||||
for(int i = 0; i < ui->hosts->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem *n = ui->hosts->topLevelItem(i);
|
||||
RDTreeWidgetItem *n = ui->hosts->topLevelItem(i);
|
||||
|
||||
RemoteHost *host = getRemoteHost(n);
|
||||
|
||||
@@ -492,7 +485,7 @@ void RemoteManager::on_hostname_textEdited(const QString &text)
|
||||
|
||||
ui->hosts->clearSelection();
|
||||
if(node)
|
||||
node->setSelected(true);
|
||||
ui->hosts->setSelectedItem(node);
|
||||
|
||||
updateConnectButton();
|
||||
}
|
||||
@@ -529,7 +522,8 @@ void RemoteManager::on_runCommand_keyPress(QKeyEvent *event)
|
||||
|
||||
void RemoteManager::on_addUpdateHost_clicked()
|
||||
{
|
||||
if(!ui->hosts->selectedItems().isEmpty() && getRemoteHost(ui->hosts->selectedItems()[0]))
|
||||
RDTreeWidgetItem *item = ui->hosts->selectedItem();
|
||||
if(item && getRemoteHost(item))
|
||||
setRunCommand();
|
||||
else
|
||||
addNewHost();
|
||||
@@ -545,10 +539,10 @@ void RemoteManager::on_refreshAll_clicked()
|
||||
|
||||
for(int i = 0; i < ui->hosts->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem *n = ui->hosts->topLevelItem(i);
|
||||
RDTreeWidgetItem *n = ui->hosts->topLevelItem(i);
|
||||
|
||||
deleteChildren(n);
|
||||
setItalic(n, true);
|
||||
n->clear();
|
||||
n->setItalic(true);
|
||||
n->setIcon(0, Icons::hourglass());
|
||||
|
||||
refreshHost(n);
|
||||
@@ -559,16 +553,17 @@ void RemoteManager::on_refreshAll_clicked()
|
||||
|
||||
void RemoteManager::on_refreshOne_clicked()
|
||||
{
|
||||
if(m_Lookups.available() || ui->hosts->selectedItems().isEmpty())
|
||||
RDTreeWidgetItem *n = ui->hosts->selectedItem();
|
||||
|
||||
if(m_Lookups.available() || !n)
|
||||
return;
|
||||
|
||||
ui->refreshOne->setEnabled(false);
|
||||
ui->refreshAll->setEnabled(false);
|
||||
|
||||
QTreeWidgetItem *n = ui->hosts->selectedItems()[0];
|
||||
{
|
||||
deleteChildren(n);
|
||||
setItalic(n, true);
|
||||
n->clear();
|
||||
n->setItalic(true);
|
||||
n->setIcon(0, Icons::hourglass());
|
||||
|
||||
refreshHost(n);
|
||||
@@ -579,10 +574,10 @@ void RemoteManager::on_refreshOne_clicked()
|
||||
|
||||
void RemoteManager::on_connect_clicked()
|
||||
{
|
||||
if(ui->hosts->selectedItems().isEmpty())
|
||||
return;
|
||||
RDTreeWidgetItem *node = ui->hosts->selectedItem();
|
||||
|
||||
QTreeWidgetItem *node = ui->hosts->selectedItems()[0];
|
||||
if(!node)
|
||||
return;
|
||||
|
||||
RemoteConnect connect = getRemoteConnect(node);
|
||||
RemoteHost *host = getRemoteHost(node);
|
||||
@@ -644,10 +639,10 @@ void RemoteManager::on_connect_clicked()
|
||||
|
||||
void RemoteManager::on_deleteHost_clicked()
|
||||
{
|
||||
if(ui->hosts->selectedItems().isEmpty())
|
||||
return;
|
||||
RDTreeWidgetItem *item = ui->hosts->selectedItem();
|
||||
|
||||
QTreeWidgetItem *item = ui->hosts->selectedItems()[0];
|
||||
if(!item)
|
||||
return;
|
||||
|
||||
RemoteHost *host = getRemoteHost(item);
|
||||
|
||||
@@ -673,7 +668,7 @@ void RemoteManager::on_deleteHost_clicked()
|
||||
delete m_Ctx.Config().RemoteHosts.takeAt(idx);
|
||||
m_Ctx.Config().Save();
|
||||
|
||||
deleteChildren(item);
|
||||
item->clear();
|
||||
|
||||
delete ui->hosts->takeTopLevelItem(ui->hosts->indexOfTopLevelItem(item));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user