2020-02-16 09:17:49 +01:00
|
|
|
/*
|
2021-04-11 12:14:46 +02:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
2020-02-16 09:17:49 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-16 09:17:49 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
2020-08-16 16:02:01 +02:00
|
|
|
#include <LibGUI/Model.h>
|
|
|
|
|
#include <LibGUI/Variant.h>
|
2020-02-16 09:17:49 +01:00
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
2020-08-16 16:02:01 +02:00
|
|
|
Variant ModelIndex::data(ModelRole role) const
|
|
|
|
|
{
|
|
|
|
|
if (!is_valid())
|
|
|
|
|
return {};
|
|
|
|
|
|
2021-02-23 20:42:32 +01:00
|
|
|
VERIFY(model());
|
2020-08-16 16:02:01 +02:00
|
|
|
return model()->data(*this, role);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-11 12:14:46 +02:00
|
|
|
ModelIndex ModelIndex::sibling(int row, int column) const
|
|
|
|
|
{
|
|
|
|
|
if (!is_valid())
|
|
|
|
|
return {};
|
|
|
|
|
VERIFY(model());
|
|
|
|
|
return model()->index(row, column, parent());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModelIndex ModelIndex::sibling_at_column(int column) const
|
|
|
|
|
{
|
|
|
|
|
if (!is_valid())
|
|
|
|
|
return {};
|
|
|
|
|
return sibling(row(), column);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 09:17:49 +01:00
|
|
|
}
|